aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/external.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-09-19 16:37:55 +0200
committerLukas Larsson <[email protected]>2019-02-21 16:38:04 +0100
commit9a7df41a9e5361049a17c8aa971b52599fba2632 (patch)
tree9084706715fd064a1011753e2e72fe49e05875ba /erts/emulator/beam/external.c
parent0184c2e0438ac42c44d14e92b13e2807e0a670b3 (diff)
downloadotp-9a7df41a9e5361049a17c8aa971b52599fba2632.tar.gz
otp-9a7df41a9e5361049a17c8aa971b52599fba2632.tar.bz2
otp-9a7df41a9e5361049a17c8aa971b52599fba2632.zip
erts: Move reason in dist messages to payload
The dist messages EXIT, EXIT2 and MONITOR_DOWN have been updated with new versions that send the reason term as part of the payload of the message instead of as part of the control message. This allows the decode of the reason to be done by the receiving process instead of the dist entry which in turn makes it possible for multiple decodes to be done in parallel. This change is done in order to make it easier to fragment the potentially large payload of EXIT, EXIT2 and MONITOR_DOWN into multiple distribution messages. OTP-15611
Diffstat (limited to 'erts/emulator/beam/external.c')
-rw-r--r--erts/emulator/beam/external.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
index 4b8040b356..640ca338d9 100644
--- a/erts/emulator/beam/external.c
+++ b/erts/emulator/beam/external.c
@@ -636,11 +636,13 @@ byte* erts_encode_ext_ets(Eterm term, byte *ep, struct erl_off_heap_header** off
}
ErtsDistExternal *
-erts_make_dist_ext_copy(ErtsDistExternal *edep, Uint xsize)
+erts_make_dist_ext_copy(ErtsDistExternal *edep, Eterm *token)
{
size_t align_sz;
size_t dist_ext_sz;
size_t ext_sz = 0;
+ size_t token_sz = 0;
+ Eterm token_size;
byte *ep;
ErtsDistExternal *new_edep;
@@ -652,8 +654,12 @@ erts_make_dist_ext_copy(ErtsDistExternal *edep, Uint xsize)
align_sz = ERTS_EXTRA_DATA_ALIGN_SZ(dist_ext_sz + ext_sz);
+ token_size = size_object(*token);
+ if (token_size)
+ token_sz = ERTS_HEAP_FRAG_SIZE(token_size);
+
new_edep = erts_alloc(ERTS_ALC_T_EXT_TERM_DATA,
- dist_ext_sz + ext_sz + align_sz + xsize);
+ dist_ext_sz + ext_sz + align_sz + token_sz);
ep = (byte *) new_edep;
sys_memcpy((void *) ep, (void *) edep, dist_ext_sz);
@@ -669,6 +675,18 @@ erts_make_dist_ext_copy(ErtsDistExternal *edep, Uint xsize)
} else {
erts_refc_inc(&new_edep->binp->intern.refc, 2);
}
+
+ /* Copy the seq_trace token */
+ if (is_not_nil(*token)) {
+ ErlHeapFragment *heap_frag;
+ ErlOffHeap *ohp;
+ Eterm *hp;
+ heap_frag = erts_dist_ext_trailer(new_edep);
+ ERTS_INIT_HEAP_FRAG(heap_frag, token_size, token_size);
+ hp = heap_frag->mem;
+ ohp = &heap_frag->off_heap;
+ *token = copy_struct(*token, token_size, &hp, ohp);
+ }
return new_edep;
}