Permalink
Browse files

Merge branch 'maint'

Conflicts:
	erts/emulator/beam/erl_nif.c
	erts/emulator/beam/erl_process.c
2 parents 856eb2e + 33b3697 commit ddb348c31e75bfa895c0959ef1e16c9e43917e8a @garazdawi garazdawi committed Aug 16, 2017
Showing with 15 additions and 7 deletions.
  1. +4 −0 erts/emulator/beam/erl_nif.c
  2. +11 −7 erts/emulator/beam/erl_process.c
@@ -587,6 +587,10 @@ int erts_flush_trace_messages(Process *c_p, ErtsProcLocks c_p_locks)
ErlTraceMessageQueue *msgq, **last_msgq;
int reds = 0;
+ /* Only one thread at a time is allowed to flush trace messages,
+ so we require the main lock to be held when doing the flush */
+ ERTS_CHK_HAVE_ONLY_MAIN_PROC_LOCK(c_p);
+
erts_proc_lock(c_p, ERTS_PROC_LOCK_TRACE);
msgq = c_p->trace_msg_q;
@@ -11403,9 +11403,11 @@ flush_dirty_trace_messages(void *vpid)
erts_free(ERTS_ALC_T_DIRTY_SL, vpid);
#endif
- proc = erts_proc_lookup(pid);
- if (proc)
- (void) erts_flush_trace_messages(proc, 0);
+ proc = erts_pid2proc_opt(NULL, 0, pid, ERTS_PROC_LOCK_MAIN, 0);
+ if (proc) {
+ (void) erts_flush_trace_messages(proc, ERTS_PROC_LOCK_MAIN);
+ erts_proc_unlock(proc, ERTS_PROC_LOCK_MAIN);
+ }
}
#endif /* ERTS_DIRTY_SCHEDULERS */
@@ -13667,16 +13669,18 @@ erts_continue_exit_process(Process *p)
have none here */
}
- erts_flush_trace_messages(p, 0);
+ erts_proc_lock(p, ERTS_PROC_LOCK_MAIN);
+ ERTS_CHK_HAVE_ONLY_MAIN_PROC_LOCK(p);
+
+#ifdef ERTS_SMP
+ erts_flush_trace_messages(p, ERTS_PROC_LOCK_MAIN);
+#endif
ERTS_TRACER_CLEAR(&ERTS_TRACER(p));
if (!delay_del_proc)
delete_process(p);
- erts_proc_lock(p, ERTS_PROC_LOCK_MAIN);
- ERTS_CHK_HAVE_ONLY_MAIN_PROC_LOCK(p);
-
return;
yield:

0 comments on commit ddb348c

Please sign in to comment.