Browse Source

NamedPipe: Avoid deadlocking on macOS when close and read are called simultaneously

pull/22/head
reuk 3 years ago
parent
commit
833fd9bde2
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 13 additions and 8 deletions
  1. +13
    -8
      modules/juce_core/native/juce_posix_NamedPipe.cpp

+ 13
- 8
modules/juce_core/native/juce_posix_NamedPipe.cpp View File

@@ -246,18 +246,23 @@ private:
void NamedPipe::close()
{
ScopedWriteLock sl (lock);
if (pimpl != nullptr)
{
pimpl->stopReadOperation = true;
const ScopedReadLock sl (lock);
if (pimpl != nullptr)
{
pimpl->stopReadOperation = true;
const char buffer[] { 0 };
const auto done = ::write (pimpl->pipeIn.get(), buffer, numElementsInArray (buffer));
ignoreUnused (done);
const char buffer[] { 0 };
const auto done = ::write (pimpl->pipeIn.get(), buffer, numElementsInArray (buffer));
ignoreUnused (done);
}
}
pimpl.reset();
{
const ScopedWriteLock sl (lock);
pimpl.reset();
}
}
bool NamedPipe::openInternal (const String& pipeName, bool createPipe, bool mustNotExist)


Loading…
Cancel
Save