Rebase against 7f0fac46d718e0961314d0c50342dcf336b9803d.

This commit is contained in:
Elizabeth Figura
2025-06-23 16:47:48 -05:00
parent 7db26cf727
commit 5054f7359b
3 changed files with 45 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
From 222ae102097fd34e6ff52813d1c0a165c7165776 Mon Sep 17 00:00:00 2001
From f4a1348aaf4998e1d5c5a8014d38326982ce5f3d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 12 Nov 2018 18:10:32 +0200
Subject: [PATCH] server: Do not signal violently terminated threads until they
@@ -22,15 +22,15 @@ no guarantee currently that the terminated thread really stopped executing.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
---
server/thread.c | 32 +++++++++++++++++++++++++++++---
server/thread.c | 31 +++++++++++++++++++++++++++++--
server/thread.h | 1 +
2 files changed, 30 insertions(+), 3 deletions(-)
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/server/thread.c b/server/thread.c
index f7e5e5fabe8..506adfc0a6f 100644
index 05ec6a4ec00..b3b971548bc 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -246,6 +246,7 @@ static inline void init_thread_structure( struct thread *thread )
@@ -422,6 +422,7 @@ static inline void init_thread_structure( struct thread *thread )
thread->token = NULL;
thread->desc = NULL;
thread->desc_len = 0;
@@ -38,24 +38,15 @@ index f7e5e5fabe8..506adfc0a6f 100644
thread->creation_time = current_time;
thread->exit_time = 0;
@@ -450,6 +451,7 @@ static void destroy_thread( struct object *obj )
@@ -642,6 +643,7 @@ static void destroy_thread( struct object *obj )
list_remove( &thread->entry );
cleanup_thread( thread );
release_object( thread->process );
+ if (thread->exit_poll) remove_timeout_user( thread->exit_poll );
if (thread->id) free_ptid( thread->id );
if (thread->token) release_object( thread->token );
}
@@ -467,7 +469,7 @@ static void dump_thread( struct object *obj, int verbose )
static int thread_signaled( struct object *obj, struct wait_queue_entry *entry )
{
struct thread *mythread = (struct thread *)obj;
- return (mythread->state == TERMINATED);
+ return mythread->state == TERMINATED && !mythread->exit_poll;
}
static unsigned int thread_map_access( struct object *obj, unsigned int access )
@@ -1275,6 +1277,26 @@ int thread_get_inflight_fd( struct thread *thread, int client )
if (thread->sync) release_object( thread->sync );
@@ -1549,6 +1551,26 @@ int thread_get_inflight_fd( struct thread *thread, int client )
return -1;
}
@@ -75,33 +66,34 @@ index f7e5e5fabe8..506adfc0a6f 100644
+ /* grab reference since object can be destroyed while trying to wake up */
+ grab_object( &thread->obj );
+ thread->exit_poll = NULL;
+ wake_up( &thread->obj, 0 );
+ signal_sync( thread->sync );
+ release_object( &thread->obj );
+}
+
/* kill a thread on the spot */
void kill_thread( struct thread *thread, int violent_death )
{
@@ -1294,8 +1316,12 @@ void kill_thread( struct thread *thread, int violent_death )
@@ -1568,8 +1590,13 @@ void kill_thread( struct thread *thread, int violent_death )
}
kill_console_processes( thread, 0 );
abandon_mutexes( thread );
- wake_up( &thread->obj, 0 );
- signal_sync( thread->sync );
- if (violent_death) send_thread_signal( thread, SIGQUIT );
+ if (violent_death)
+ {
+ send_thread_signal( thread, SIGQUIT );
+ check_terminated( thread );
+ }
+ else wake_up( &thread->obj, 0 );
+ else
+ signal_sync( thread->sync );
cleanup_thread( thread );
remove_process_thread( thread->process, thread );
release_object( thread );
diff --git a/server/thread.h b/server/thread.h
index a1bc5060bb9..edf2a825451 100644
index 58081be7481..d87f84603ef 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -93,6 +93,7 @@ struct thread
@@ -95,6 +95,7 @@ struct thread
data_size_t desc_len; /* thread description length in bytes */
WCHAR *desc; /* thread description string */
struct completion_wait *completion_wait; /* completion port wait object the thread is associated with */
@@ -110,5 +102,5 @@ index a1bc5060bb9..edf2a825451 100644
extern struct thread *current;
--
2.45.2
2.47.2