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:
parent
170602f7d0
commit
fc2ce88576
1 changed files with 16 additions and 5 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue