From: svost Date: Sat, 18 Apr 2015 20:00:01 +0000 (+0300) Subject: Merged from bitcoin: X-Git-Tag: nvc-v0.5.3~30^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=17a6c72f2ee4421c07d002983a1f11645b008934 Merged from bitcoin: https://github.com/bitcoin/bitcoin/commit/3427517d507a938074a50fa8ea6dfe3d13bef357#diff-9a82240fe7dfe86564178691cc57f2f1 --- diff --git a/src/main.cpp b/src/main.cpp index 21eef1e..83afc78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4103,3 +4103,25 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } return true; } + + +class CMainCleanup +{ +public: + CMainCleanup() {} + ~CMainCleanup() { + // block headers + std::map::iterator it1 = mapBlockIndex.begin(); + for (; it1 != mapBlockIndex.end(); it1++) + delete (*it1).second; + mapBlockIndex.clear(); + + // orphan blocks + std::map::iterator it2 = mapOrphanBlocks.begin(); + for (; it2 != mapOrphanBlocks.end(); it2++) + delete (*it2).second; + mapOrphanBlocks.clear(); + + // orphan transactions + } +} instance_of_cmaincleanup; \ No newline at end of file diff --git a/src/net.cpp b/src/net.cpp index 4f99447..0c166eb 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -600,12 +600,12 @@ void ThreadSocketHandler(void* parg) printf("ThreadSocketHandler exited\n"); } +static list vNodesDisconnected; + void ThreadSocketHandler2(void* parg) { printf("ThreadSocketHandler started\n"); - list vNodesDisconnected; unsigned int nPrevNodeCount = 0; - while (true) { // @@ -1982,6 +1982,7 @@ bool StopNode() Sleep(20); Sleep(50); DumpAddresses(); + return true; } @@ -2002,6 +2003,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();