Alexandre Julliard : server: Only keep the running processes in the global process list.
Alexandre Julliard
julliard at winehq.org
Thu Mar 11 15:59:35 CST 2021
Module: wine
Branch: master
Commit: d316d548c2006b14efd5e822be05e83f3cbc7d6f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d316d548c2006b14efd5e822be05e83f3cbc7d6f
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Mar 11 18:09:42 2021 +0100
server: Only keep the running processes in the global process list.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/process.c | 1 -
server/console.c | 3 +--
server/process.c | 21 +++++++--------------
3 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index 108851000ff..1c47f8a3b64 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -4231,7 +4231,6 @@ static void test_dead_process(void)
}
offset += spi->NextEntryOffset;
} while (spi->NextEntryOffset);
- todo_wine
ok( !found, "process still enumerated\n" );
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
diff --git a/server/console.c b/server/console.c
index 92bda51846c..848ee6e8d98 100644
--- a/server/console.c
+++ b/server/console.c
@@ -649,8 +649,7 @@ static int propagate_console_signal_cb(struct process *process, void *user)
{
struct console_signal_info* csi = (struct console_signal_info*)user;
- if (process->console == csi->console && process->running_threads &&
- (!csi->group || process->group_id == csi->group))
+ if (process->console == csi->console && (!csi->group || process->group_id == csi->group))
{
/* find a suitable thread to signal */
struct thread *thread;
diff --git a/server/process.c b/server/process.c
index e5fe7cc6b6e..0d550328312 100644
--- a/server/process.c
+++ b/server/process.c
@@ -559,7 +559,6 @@ struct process *create_process( int fd, struct process *parent, int inherit_all,
list_init( &process->rawinput_devices );
process->end_time = 0;
- list_add_tail( &process_list, &process->entry );
if (sd && !default_set_sd( &process->obj, sd, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION ))
@@ -646,7 +645,6 @@ static void process_destroy( struct object *obj )
}
if (process->console) release_object( process->console );
if (process->msg_fd) release_object( process->msg_fd );
- list_remove( &process->entry );
if (process->idle_event) release_object( process->idle_event );
if (process->id) free_ptid( process->id );
if (process->token) release_object( process->token );
@@ -804,15 +802,11 @@ restart:
/* kill all processes */
static void kill_all_processes(void)
{
- for (;;)
- {
- struct process *process;
+ struct list *ptr;
- LIST_FOR_EACH_ENTRY( process, &process_list, struct process, entry )
- {
- if (process->running_threads) break;
- }
- if (&process->entry == &process_list) break; /* no process found */
+ while ((ptr = list_head( &process_list )))
+ {
+ struct process *process = LIST_ENTRY( ptr, struct process, entry );
terminate_process( process, NULL, 1 );
}
}
@@ -828,7 +822,6 @@ void kill_console_processes( struct thread *renderer, int exit_code )
LIST_FOR_EACH_ENTRY( process, &process_list, struct process, entry )
{
if (process == renderer->process) continue;
- if (!process->running_threads) continue;
if (process->console && console_get_renderer( process->console ) == renderer) break;
}
if (&process->entry == &process_list) break; /* no process found */
@@ -875,6 +868,7 @@ void add_process_thread( struct process *process, struct thread *thread )
list_add_tail( &process->thread_list, &thread->proc_entry );
if (!process->running_threads++)
{
+ list_add_tail( &process_list, &process->entry );
running_processes++;
if (!process->is_system)
{
@@ -901,6 +895,7 @@ void remove_process_thread( struct process *process, struct thread *thread )
/* we have removed the last running thread, exit the process */
process->exit_code = thread->exit_code;
generate_debug_event( thread, DbgExitProcessStateChange, process );
+ list_remove( &process->entry );
process_killed( process );
}
else generate_debug_event( thread, DbgExitThreadStateChange, thread );
@@ -979,10 +974,8 @@ void detach_debugged_processes( struct debug_obj *debug_obj, int exit_code )
/* find the first process being debugged by 'debugger' and still running */
LIST_FOR_EACH_ENTRY( process, &process_list, struct process, entry )
- {
- if (!process->running_threads) continue;
if (process->debug_obj == debug_obj) break;
- }
+
if (&process->entry == &process_list) break; /* no process found */
if (exit_code)
{
More information about the wine-cvs
mailing list