Skip to content

Commit 0bbc115

Browse files
Updated subscriber listening connections to use connect action mutex on disconnect
This prevents socket startup / shutdown issues for fast sequence restart operations
1 parent 88728f8 commit 0bbc115

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lib/transport/DataSubscriber.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,8 @@ void DataSubscriber::Disconnect(const bool joinThread, const bool autoReconnecti
12621262
return;
12631263
}
12641264

1265+
bool useConnectActionMutex = !autoReconnecting || m_listening;
1266+
12651267
// Notify running threads that the subscriber is disconnecting, i.e., disconnect thread is active
12661268
m_disconnecting = true;
12671269
m_connected = false;
@@ -1277,7 +1279,7 @@ void DataSubscriber::Disconnect(const bool joinThread, const bool autoReconnecti
12771279
{
12781280
ScopeLock lock(m_disconnectThreadMutex);
12791281

1280-
m_disconnectThread = Thread([this, autoReconnecting, includeListener]
1282+
m_disconnectThread = Thread([this, autoReconnecting, includeListener, useConnectActionMutex]
12811283
{
12821284
try
12831285
{
@@ -1286,9 +1288,11 @@ void DataSubscriber::Disconnect(const bool joinThread, const bool autoReconnecti
12861288
{
12871289
m_connector.Cancel();
12881290
m_connectionTerminationThread.join();
1289-
m_connectActionMutex.lock();
12901291
}
12911292

1293+
if (useConnectActionMutex)
1294+
m_connectActionMutex.lock();
1295+
12921296
ErrorCode error;
12931297

12941298
// Release queues and close sockets so that threads can shut down gracefully
@@ -1340,10 +1344,9 @@ void DataSubscriber::Disconnect(const bool joinThread, const bool autoReconnecti
13401344
if (m_autoReconnectCallback != nullptr && !m_disposing)
13411345
m_autoReconnectCallback(this);
13421346
}
1343-
else
1344-
{
1347+
1348+
if (useConnectActionMutex)
13451349
m_connectActionMutex.unlock();
1346-
}
13471350
});
13481351
}
13491352

0 commit comments

Comments
 (0)