diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-03-29 02:17:10 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2013-03-29 02:24:18 +0100 |
commit | 3427517d507a938074a50fa8ea6dfe3d13bef357 (patch) | |
tree | 38ca3337c8c91e7a55423ca7f26fe5319f112085 /src/net.cpp | |
parent | dfd71bb4509d12c26e630bc671a542ad5bab4945 (diff) |
Clean up global datastructures at shutdown.
This should make detecting leaks much easier.
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp index 3406a28b0e..ed2e662fd8 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -660,12 +660,12 @@ void ThreadSocketHandler(void* parg) printf("ThreadSocketHandler exited\n"); } +static list<CNode*> vNodesDisconnected; + void ThreadSocketHandler2(void* parg) { printf("ThreadSocketHandler started\n"); - list<CNode*> vNodesDisconnected; unsigned int nPrevNodeCount = 0; - loop { // @@ -1992,6 +1992,7 @@ bool StopNode() Sleep(20); Sleep(50); DumpAddresses(); + return true; } @@ -2012,6 +2013,18 @@ public: if (closesocket(hListenSocket) == SOCKET_ERROR) printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); + // clean up some globals (to help leak detection) + BOOST_FOREACH(CNode *pnode, vNodes) + delete pnode; + BOOST_FOREACH(CNode *pnode, vNodesDisconnected) + delete pnode; + vNodes.clear(); + vNodesDisconnected.clear(); + delete semOutbound; + semOutbound = NULL; + delete pnodeLocalHost; + pnodeLocalHost = NULL; + #ifdef WIN32 // Shutdown Windows Sockets WSACleanup(); |