Browse Source

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.
tags/2021-05-28
reuk 4 years ago
parent
commit
5a19a7c8e8
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      modules/juce_core/native/juce_win32_Files.cpp

+ 2
- 2
modules/juce_core/native/juce_win32_Files.cpp 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);


Loading…
Cancel
Save