Skip to content

Commit e007b24

Browse files
committed
Fix shutdown hang with >= 8 -addnodes set
We previously would block waiting for a CSemaphoreGrant in ThreadOpenAddedConnections, when we did not need to. This would block as the posts in CConnman shutdown were both to the wrong semaphore and in the wrong location.
1 parent 6996e06 commit e007b24

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/net.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,10 @@ void CConnman::Interrupt()
23222322
if (semOutbound)
23232323
for (int i=0; i<(nMaxOutbound + nMaxFeeler); i++)
23242324
semOutbound->post();
2325+
2326+
if (semAddnode)
2327+
for (int i=0; i<nMaxAddnode; i++)
2328+
semAddnode->post();
23252329
}
23262330

23272331
void CConnman::Stop()
@@ -2337,10 +2341,6 @@ void CConnman::Stop()
23372341
if (threadSocketHandler.joinable())
23382342
threadSocketHandler.join();
23392343

2340-
if (semAddnode)
2341-
for (int i=0; i<nMaxAddnode; i++)
2342-
semOutbound->post();
2343-
23442344
if (fAddressesInitialized)
23452345
{
23462346
DumpData();

0 commit comments

Comments
 (0)