server: Avoid removing thread twice from its desktop thread list.

This commit is contained in:
Rémi Bernon 2024-03-21 18:49:56 +01:00 committed by Alexandre Julliard
parent b13477deb4
commit 5d91ab65fa

View file

@ -403,14 +403,10 @@ static void add_desktop_thread( struct desktop *desktop, struct thread *thread )
}
/* remove a user of the desktop and start the close timeout if necessary */
static void remove_desktop_thread( struct desktop *desktop, struct thread *thread )
static void remove_desktop_user( struct desktop *desktop, struct thread *thread )
{
struct process *process;
list_remove( &thread->desktop_entry );
if (!thread->process->is_system)
{
assert( desktop->users > 0 );
desktop->users--;
@ -419,6 +415,13 @@ static void remove_desktop_thread( struct desktop *desktop, struct thread *threa
desktop->close_timeout = add_timeout_user( -TICKS_PER_SEC, close_desktop_timeout, desktop );
}
/* remove a thread from the list of threads attached to a desktop */
static void remove_desktop_thread( struct desktop *desktop, struct thread *thread )
{
list_remove( &thread->desktop_entry );
if (!thread->process->is_system) remove_desktop_user( desktop, thread );
if (desktop == desktop->winstation->input_desktop)
{
/* thread process might still be connected the input desktop through another thread, update the full list */
@ -546,7 +549,8 @@ void release_thread_desktop( struct thread *thread, int close )
if (!(desktop = get_desktop_obj( thread->process, handle, 0 ))) clear_error(); /* ignore errors */
else
{
remove_desktop_thread( desktop, thread );
if (close) remove_desktop_thread( desktop, thread );
else remove_desktop_user( desktop, thread );
release_object( desktop );
}