wsd: correctly set termination and shutdown flag

We should always set the shutdown flag first.
Otherwise, we run afoul of a race condition.

Change-Id: Ic99793d68b3b943496ff932b4bdafd336fef7f82
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
Ashod Nakashian 2022-04-29 07:43:42 -04:00 committed by Michael Meeks
parent c5e533f943
commit 4bf085f195

View file

@ -65,11 +65,16 @@ namespace SigUtil
void setTerminationFlag()
{
#if !MOBILEAPP
// Request shutting down first. Otherwise, we can race with
// getTerminationFlag, which asserts ShutdownRequestFlag.
ShutdownRequestFlag = true;
#endif
// Set the forced-termination flag.
TerminationFlag = true;
#if !MOBILEAPP
// And request shutting down and wake-up the thread.
requestShutdown();
// And wake-up the thread.
SocketPoll::wakeupWorld();
#endif
}