Skip to content

Commit

Permalink
Fix connection bug when reloading a signal chain
Browse files Browse the repository at this point in the history
Caused by closing and re-opening the data and listen sockets on the same port number when loading a signal chain.
  • Loading branch information
anjaldoshi committed May 22, 2023
1 parent 85f5657 commit ef21a89
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions Source/ZmqInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ void ZmqInterface::openListenSocket()
int ZmqInterface::closeListenSocket()
{
int rc = 0;

LOGD("Closing listening socket");

stopTimer();

stopThread(500);

if (listenSocket)
{
LOGD("Closing listening socket");

stopTimer();

stopThread(500);

rc = zmq_close(listenSocket);
listenSocket = nullptr;
}
Expand Down Expand Up @@ -783,13 +783,18 @@ void ZmqInterface::parameterValueChanged(Parameter* param)
}
else if (param->getName().equalsIgnoreCase("data_port"))
{
// close previous sockets and assign new ports
int newDataPort = static_cast<IntParameter*>(param)->getIntValue();

closeListenSocket();
closeDataSocket();
dataPort = static_cast<IntParameter*>(param)->getIntValue();
listenPort = dataPort + 1;
openListenSocket();
openDataSocket();
if(dataPort != newDataPort)
{
// close previous sockets and assign new ports

closeListenSocket();
closeDataSocket();
dataPort = newDataPort;
listenPort = dataPort + 1;
openListenSocket();
openDataSocket();
}
}
}

0 comments on commit ef21a89

Please sign in to comment.