1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-02 03:20:06 +00:00

IPC: Fix potential deadlock in win32 NamedPipe implementation

We use a manual-reset event rather than an auto-reset event to cancel IO
on the pipe. This avoids unlucky cases where new IO would start just
after signalling the event and would block indefinitely while waiting on
the newly-unsignalled event.
This commit is contained in:
reuk 2020-11-25 12:31:20 +00:00
parent c5136d28b7
commit 5a19a7c8e8

View file

@ -975,7 +975,7 @@ public:
Pimpl (const String& pipeName, const bool createPipe, bool mustNotExist)
: filename ("\\\\.\\pipe\\" + File::createLegalFileName (pipeName)),
pipeH (INVALID_HANDLE_VALUE),
cancelEvent (CreateEvent (nullptr, FALSE, FALSE, nullptr)),
cancelEvent (CreateEvent (nullptr, TRUE, FALSE, nullptr)),
connected (false), ownsPipe (createPipe), shouldStop (false)
{
if (createPipe)
@ -1157,7 +1157,7 @@ private:
}
HANDLE handles[] = { over.over.hEvent, cancelEvent };
DWORD waitResult = WaitForMultipleObjects (2, handles, FALSE,
DWORD waitResult = WaitForMultipleObjects (numElementsInArray (handles), handles, FALSE,
timeOutMilliseconds >= 0 ? (DWORD) timeOutMilliseconds
: INFINITE);