1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-19 01:04:20 +00:00

IPC: Avoid deadlocks when destroying pipes

Previously, calls to `open` blocked when creating a writeable pipe.

This could cause other calls to block indefinitely, waiting for the pipe
to become available.

Now, we open the pipe in nonblocking mode, which allows us to retry
indefinitely, checking `stopReadOperation` each time to find out whether
`close` has been called and allowing a graceful exit.
This commit is contained in:
reuk 2020-11-16 20:12:06 +00:00
parent 472fac976b
commit 84be2fea9a
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -154,7 +154,7 @@ private:
bool openPipe (bool isInput, uint32 timeoutEnd)
{
auto& pipe = isInput ? pipeIn : pipeOut;
int flags = isInput ? O_RDWR | O_NONBLOCK : O_WRONLY;
int flags = (isInput ? O_RDWR : O_WRONLY) | O_NONBLOCK;
const String& pipeName = isInput ? (createdPipe ? pipeInName : pipeOutName)
: (createdPipe ? pipeOutName : pipeInName);