Rémi Bernon (@rbernon) commented about dlls/windows.media.speech/recognizer.c:
- HANDLE thread;
- EnterCriticalSection(&session->cs);
- thread = session->worker_thread;
- LeaveCriticalSection(&session->cs);
- if (thread)
- {
WaitForSingleObject(thread, INFINITE);
CloseHandle(thread);
EnterCriticalSection(&session->cs);
session->worker_thread = NULL;
LeaveCriticalSection(&session->cs);
- }
Although I think it's okay given the rest of the code, I feel a bit unsafe about this CS re-entry.
I think that maybe it would be better to read and reset `session->worker_thread` to `NULL` at once, although I haven't completely thought about its effect on consistency.
You could also arguably drop the condition and wait and close on the resulting thread even if it is `NULL`, as a `NULL` handle will just do nothing.