summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/erl_message.c
diff options
context:
space:
mode:
authorRickard Green <rickard@erlang.org>2020-03-26 16:31:17 +0100
committerRickard Green <rickard@erlang.org>2020-04-04 18:53:45 +0200
commitc083cac55dce97fc70df15d614de7eb28e42b7f6 (patch)
tree90e1cc4fc662f967f6fa7ffaa90e404cc7c44dea /erts/emulator/beam/erl_message.c
parent5b526169ea616e87a7145d2a996b94a91879f200 (diff)
downloaderlang-c083cac55dce97fc70df15d614de7eb28e42b7f6.tar.gz
Fix handling of receive marker
* Ensure that deferred-save is updated when when we resolve deferred-save-last. That is, keep deferred-save as long as we have deferred-save-last. * Ensure that deferred-save-last eventually is resolved. A steady flow of new signals could prevent deferred-save-last from ever being resolved.
Diffstat (limited to 'erts/emulator/beam/erl_message.c')
-rw-r--r--erts/emulator/beam/erl_message.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/erts/emulator/beam/erl_message.c b/erts/emulator/beam/erl_message.c
index 3fb1be3e8b..2b13199698 100644
--- a/erts/emulator/beam/erl_message.c
+++ b/erts/emulator/beam/erl_message.c
@@ -334,9 +334,6 @@ erts_queue_dist_message(Process *rcvr,
else {
LINK_MESSAGE(rcvr, mp);
- if (rcvr_locks & ERTS_PROC_LOCK_MAIN)
- erts_proc_sig_fetch(rcvr);
-
if (!(rcvr_locks & ERTS_PROC_LOCK_MSGQ))
erts_proc_unlock(rcvr, ERTS_PROC_LOCK_MSGQ);
@@ -401,9 +398,6 @@ queue_messages(Process* receiver,
erts_enqueue_signals(receiver, first, last, NULL, len, state);
}
- if (receiver_locks & ERTS_PROC_LOCK_MAIN)
- erts_proc_sig_fetch(receiver);
-
if (locked_msgq) {
erts_proc_unlock(receiver, ERTS_PROC_LOCK_MSGQ);
}
@@ -641,12 +635,16 @@ erts_send_message(Process* sender,
Eterm utag = NIL;
#endif
erts_aint32_t receiver_state;
+#ifdef ERTS_ENABLE_LOCK_CHECK
+ int have_receiver_main_lock = 0;
+#endif
#ifdef SHCOPY_SEND
erts_shcopy_t info;
#else
erts_literal_area_t litarea;
INITIALIZE_LITERAL_PURGE_AREA(litarea);
#endif
+
#ifdef USE_VM_PROBES
*sender_name = *receiver_name = '\0';
@@ -704,6 +702,13 @@ erts_send_message(Process* sender,
+ seq_trace_size),
&hp,
&ohp);
+#ifdef ERTS_ENABLE_LOCK_CHECK
+ if ((*receiver_locks) & ERTS_PROC_LOCK_MAIN) {
+ have_receiver_main_lock = 1;
+ erts_proc_lc_require_lock(receiver, ERTS_PROC_LOCK_MAIN,
+ __FILE__, __LINE__);
+ }
+#endif
#ifdef SHCOPY_SEND
if (is_not_immed(message))
@@ -741,6 +746,12 @@ erts_send_message(Process* sender,
if (receiver == sender && !(receiver_state & ERTS_PSFLG_OFF_HEAP_MSGQ)) {
mp = erts_alloc_message(0, NULL);
msize = 0;
+#ifdef ERTS_ENABLE_LOCK_CHECK
+ ASSERT((*receiver_locks) & ERTS_PROC_LOCK_MAIN);
+ have_receiver_main_lock = 1;
+ erts_proc_lc_require_lock(receiver, ERTS_PROC_LOCK_MAIN,
+ __FILE__, __LINE__);
+#endif
}
else {
#ifdef SHCOPY_SEND
@@ -755,6 +766,13 @@ erts_send_message(Process* sender,
msize,
&hp,
&ohp);
+#ifdef ERTS_ENABLE_LOCK_CHECK
+ if ((*receiver_locks) & ERTS_PROC_LOCK_MAIN) {
+ have_receiver_main_lock = 1;
+ erts_proc_lc_require_lock(receiver, ERTS_PROC_LOCK_MAIN,
+ __FILE__, __LINE__);
+ }
+#endif
#ifdef SHCOPY_SEND
if (is_not_immed(message))
message = copy_shared_perform(message, msize, &info, &hp, ohp);
@@ -777,6 +795,11 @@ erts_send_message(Process* sender,
erts_queue_proc_message(sender, receiver, *receiver_locks, mp, message);
+#ifdef ERTS_ENABLE_LOCK_CHECK
+ if (have_receiver_main_lock)
+ erts_proc_lc_unrequire_lock(receiver, ERTS_PROC_LOCK_MAIN);
+#endif
+
if (msize > ERTS_MSG_COPY_WORDS_PER_REDUCTION) {
Uint reds = msize / ERTS_MSG_COPY_WORDS_PER_REDUCTION;
if (reds > CONTEXT_REDS)