1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed a bug where InterprocessConnection::isConnected() returned false inside the InterprocessConnection::connectionMade() callback in some cases

This commit is contained in:
ed 2019-02-18 16:34:04 +00:00
parent 464b1f8eb2
commit 9ddf8eece2
2 changed files with 9 additions and 1 deletions

View file

@ -59,6 +59,7 @@ bool InterprocessConnection::connectToSocket (const String& hostName,
if (socket->connect (hostName, portNumber, timeOutMillisecs))
{
threadIsRunning = true;
connectionMadeInt();
thread->startThread();
return true;
@ -130,7 +131,7 @@ bool InterprocessConnection::isConnected() const
return ((socket != nullptr && socket->isConnected())
|| (pipe != nullptr && pipe->isOpen()))
&& thread->isThreadRunning();
&& threadIsRunning;
}
String InterprocessConnection::getConnectedHostName() const
@ -179,6 +180,8 @@ void InterprocessConnection::initialiseWithSocket (StreamingSocket* newSocket)
{
jassert (socket == nullptr && pipe == nullptr);
socket.reset (newSocket);
threadIsRunning = true;
connectionMadeInt();
thread->startThread();
}
@ -187,6 +190,8 @@ void InterprocessConnection::initialiseWithPipe (NamedPipe* newPipe)
{
jassert (socket == nullptr && pipe == nullptr);
pipe.reset (newPipe);
threadIsRunning = true;
connectionMadeInt();
thread->startThread();
}
@ -366,6 +371,8 @@ void InterprocessConnection::runThread()
if (thread->threadShouldExit() || ! readNextMessage())
break;
}
threadIsRunning = false;
}
} // namespace juce

View file

@ -198,6 +198,7 @@ private:
struct ConnectionThread;
std::unique_ptr<ConnectionThread> thread;
std::atomic<bool> threadIsRunning { false };
void runThread();
int writeData (void*, int);