1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-22 01:34:21 +00:00

Prevented accidental opening of already-open named pipes on win32.

This commit is contained in:
jules 2015-06-30 15:27:44 +01:00
parent 170602f7d0
commit fc2ce88576

View file

@ -795,18 +795,19 @@ public:
connected (false), ownsPipe (createPipe), shouldStop (false)
{
if (createPipe)
{
pipeH = CreateNamedPipe (filename.toWideCharPointer(),
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0,
PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, 0);
if (GetLastError() == ERROR_ALREADY_EXISTS)
closePipeHandle();
}
}
~Pimpl()
{
disconnectPipe();
if (pipeH != INVALID_HANDLE_VALUE)
CloseHandle (pipeH);
closePipeHandle();
CloseHandle (cancelEvent);
}
@ -868,6 +869,16 @@ public:
}
}
void closePipeHandle()
{
if (pipeH != INVALID_HANDLE_VALUE)
{
disconnectPipe();
CloseHandle (pipeH);
pipeH = INVALID_HANDLE_VALUE;
}
}
int read (void* destBuffer, const int maxBytesToRead, const int timeOutMilliseconds)
{
while (connect (timeOutMilliseconds))