server: Track desktop users per thread instead of per process.
commit769a2616aec500df19e92c47886df3cf99b4d51d
authorRémi Bernon <rbernon@codeweavers.com>
Wed, 21 Apr 2021 08:38:15 +0000 (21 10:38 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 21 Apr 2021 19:00:33 +0000 (21 21:00 +0200)
treecb7e8c19b8bf071ac179186574d38c9116828bec
parent9b3d5b8e5e3764920b78626f48315be0b119d7b2
server: Track desktop users per thread instead of per process.

As some thread may use a different desktop from their process.

This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.

Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.

Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.

Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
server/process.c
server/thread.c
server/user.h
server/winstation.c