From: Florin Postolache Date: Thu, 11 May 2023 19:48:53 +0000 (+0300) Subject: lib/posix-process: Fix debug printing of TIDs X-Git-Tag: RELEASE-0.13.0~18 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7eac25ea53ae833294652d6f38d04732612145b6;p=unikraft%2Funikraft.git lib/posix-process: Fix debug printing of TIDs This commit makes so that the correct info will be printed when the current thread gets killed. Before, instead of the actual TID, the empty TID from the iterator would be printed. Signed-off-by: Florin Postolache Reviewed-by: Simon Kuenzer Reviewed-by: Andra Paraschiv Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #885 --- diff --git a/lib/posix-process/process.c b/lib/posix-process/process.c index 02ad05fbb..a98dac7e2 100644 --- a/lib/posix-process/process.c +++ b/lib/posix-process/process.c @@ -328,8 +328,7 @@ static void pprocess_release(struct posix_process *pprocess) static void pprocess_kill(struct posix_process *pprocess) { - struct posix_thread *pthread, *pthreadn; - bool self_destruct = false; + struct posix_thread *pthread, *pthreadn, *pthread_self = NULL; /* Kill all remaining threads of the process */ uk_list_for_each_entry_safe(pthread, pthreadn, @@ -343,7 +342,7 @@ static void pprocess_kill(struct posix_process *pprocess) * function is executed anymore as soon as the * thread killed itself. */ - self_destruct = true; + pthread_self = pthread; continue; } if (uk_thread_is_exited(pthread->thread)) { @@ -365,9 +364,9 @@ static void pprocess_kill(struct posix_process *pprocess) uk_sched_thread_terminate(pthread->thread); } - if (self_destruct) { + if (pthread_self) { uk_pr_debug("Terminating PID %d: Self-killing TID %d...\n", - pprocess->pid, pthread->tid); + pprocess->pid, pthread_self->tid); uk_sched_thread_terminate(uk_thread_current()); /* NOTE: Nothing will be executed from here on */ @@ -413,7 +412,7 @@ static int posix_thread_init(struct uk_thread *child, struct uk_thread *parent) } if (!parent_pthread) { /* parent has no posix thread, do not setup one for the child */ - uk_pr_debug("thread %p (%s): Parent %p (%s) has no PID, skipping...\n", + uk_pr_debug("thread %p (%s): Parent %p (%s) without process context, skipping...\n", child, child->name, parent, parent ? parent->name : ""); pthread_self = NULL;