From 8ad663c1fa88d68843e45580deced56112343183 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Thu, 6 Jul 2017 13:40:09 -0400 Subject: net: use an interface class rather than signals for message processing Drop boost signals in favor of a stateful class. This will allow the message processing loop to actually move to net_processing in a future step. --- src/init.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index c70c0274b..9e8029971 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -195,11 +195,10 @@ void Shutdown() #endif MapPort(false); UnregisterValidationInterface(peerLogic.get()); - peerLogic.reset(); g_connman.reset(); + peerLogic.reset(); StopTorControl(); - UnregisterNodeSignals(GetNodeSignals()); if (fDumpMempoolLater && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { DumpMempool(); } @@ -1268,7 +1267,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) peerLogic.reset(new PeerLogicValidation(&connman)); RegisterValidationInterface(peerLogic.get()); - RegisterNodeSignals(GetNodeSignals()); // sanitize comments per BIP-0014, format user agent and check total size std::vector uacomments; @@ -1659,6 +1657,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) connOptions.nMaxFeeler = 1; connOptions.nBestHeight = chainActive.Height(); connOptions.uiInterface = &uiInterface; + connOptions.m_msgproc = peerLogic.get(); connOptions.nSendBufferMaxSize = 1000*gArgs.GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER); connOptions.nReceiveFloodSize = 1000*gArgs.GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); -- cgit v1.2.3 From 2525b972af6645ca239ac1078cffb132b402bfbb Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Thu, 7 Sep 2017 14:26:20 -0400 Subject: net: stop both net/net_processing before destroying them This should avoid either attempting to use an invalid reference/pointer to the other. --- src/init.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index 9e8029971..810368b9d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -194,9 +194,13 @@ void Shutdown() } #endif MapPort(false); + + // Because these depend on each-other, we make sure that neither can be + // using the other before destroying them. UnregisterValidationInterface(peerLogic.get()); - g_connman.reset(); + g_connman->Stop(); peerLogic.reset(); + g_connman.reset(); StopTorControl(); if (fDumpMempoolLater && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { -- cgit v1.2.3