[LibOS] Instruct thread_exit() to send IPC_CLD_EXIT only once

Previously, when a thread exited via thread_exit(), it could send two
identical IPC_CLD_EXIT messages under certain conditions. This commit
fixes this bug and forces thread_exit() to send IPC_CLD_EXIT at most once.
This commit is contained in:
Dmitrii Kuvaiskii
2019-07-19 01:03:41 -07:00
parent e7147f7ad2
commit 61be1b2e40
+6 -2
View File
@@ -44,10 +44,14 @@ void release_clear_child_id (int * clear_child_tid);
int thread_exit(struct shim_thread * self, bool send_ipc)
{
bool sent_exit_msg = false;
/* Chia-Che: Broadcast exit message as early as possible,
so other process can start early on responding. */
if (self->in_vm && send_ipc)
if (self->in_vm && send_ipc) {
ipc_cld_exit_send(self->ppid, self->tid, self->exit_code, self->term_signal);
sent_exit_msg = true;
}
lock(&self->lock);
@@ -99,7 +103,7 @@ int thread_exit(struct shim_thread * self, bool send_ipc)
unlock(&parent->lock);
DkEventSet(parent->child_exit_event);
} else {
} else if (!sent_exit_msg) {
debug("parent not here, need to tell another process\n");
ipc_cld_exit_send(self->ppid, self->tid, self->exit_code, self->term_signal);
}