From 84be2fea9a2867322b98ae4bf9610c61a67dd15d Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 16 Nov 2020 20:12:06 +0000 Subject: [PATCH] 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. --- modules/juce_core/native/juce_posix_NamedPipe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_posix_NamedPipe.cpp b/modules/juce_core/native/juce_posix_NamedPipe.cpp index 2321d45b2f..9c5a1d8fa3 100644 --- a/modules/juce_core/native/juce_posix_NamedPipe.cpp +++ b/modules/juce_core/native/juce_posix_NamedPipe.cpp @@ -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);