Fix usage of TerminateThread() causing critical section corruption.
authorJehan <jehan@girinstud.io>
Wed, 20 Nov 2019 11:21:35 +0000 (12:21 +0100)
committerJehan <jehan@girinstud.io>
Wed, 20 Nov 2019 12:00:49 +0000 (13:00 +0100)
commit1f6071590d5b4fa3b52aa1456a9648ae354b2c7a
tree7a21515363d5a07e378f8d6d2086e37d5ff94091
parent73128f3883e3fb37523bb4ce032e261d679e9024
Fix usage of TerminateThread() causing critical section corruption.

This patch was submitted to the GIMP project by a publisher wishing to
keep confidentiality (hence anonymously). I just pass along the patch.
Here is the patch explanation which came with:

First they remind us what Microsoft documentation says about
TerminateThread:
> TerminateThread is a dangerous function that should only be used in
> the most extreme cases. You should call TerminateThread only if you
> know exactly what the target thread is doing, and you control all of
> the code that the target thread could possibly be running at the time
> of the termination.
(https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread)

Then they say that 5 milliseconds time-out might not be long enough for
the thread to exit gracefully. They propose to set it to a much higher
value (for instance here 5 seconds).

And finally you should always check the return value of
WaitForSingleObject(). In particular you want to run TerminateThread()
only if WaitForSingleObject() failed, not on success case.
driver/others/blas_server_win32.c