From f1e1fb4bdef878c8fc1564fa418d44e7541a7e83 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Tue, 7 Sep 2010 01:12:53 +0000 Subject: cleanup, catch some recoverable exceptions and continue git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@148 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- net.cpp | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) (limited to 'net.cpp') diff --git a/net.cpp b/net.cpp index 9aaa38f32..d1fdd241b 100644 --- a/net.cpp +++ b/net.cpp @@ -25,7 +25,6 @@ CNode* pnodeLocalHost = NULL; uint64 nLocalHostNonce = 0; array vnThreadsRunning; SOCKET hListenSocket = INVALID_SOCKET; -int64 nThreadSocketHandlerHeartbeat = INT64_MAX; vector vNodes; CCriticalSection cs_vNodes; @@ -789,7 +788,6 @@ void ThreadSocketHandler2(void* parg) pnode->Release(); } - nThreadSocketHandlerHeartbeat = GetTime(); Sleep(10); } } @@ -1364,57 +1362,6 @@ void StartNode(void* parg) // Generate coins in the background GenerateBitcoins(fGenerateBitcoins); - - // - // Thread monitoring - // Not really needed anymore, the cause of the hanging was fixed - // - loop - { - Sleep(1000); - if (fShutdown) - return; - if (GetTime() - nThreadSocketHandlerHeartbeat > 15 * 60) - { - // First see if closing sockets will free it - printf("*** ThreadSocketHandler is stopped ***\n"); - CRITICAL_BLOCK(cs_vNodes) - { - foreach(CNode* pnode, vNodes) - { - bool fGot = false; - TRY_CRITICAL_BLOCK(pnode->cs_vRecv) - TRY_CRITICAL_BLOCK(pnode->cs_vSend) - fGot = true; - if (!fGot) - { - printf("*** closing socket\n"); - pnode->CloseSocketDisconnect(); - } - } - } - Sleep(10000); - if (fShutdown) - return; - if (GetTime() - nThreadSocketHandlerHeartbeat < 60) - continue; - - // Hopefully it never comes to this. - // We know it'll always be hung in the recv or send call. - // cs_vRecv or cs_vSend may be left permanently unreleased, - // but we always only use TRY_CRITICAL_SECTION on them. - printf("*** Restarting ThreadSocketHandler ***\n"); - TerminateThread(hThreadSocketHandler, 0); - #ifdef __WXMSW__ - CloseHandle(hThreadSocketHandler); - #endif - vnThreadsRunning[0] = 0; - - // Restart - hThreadSocketHandler = CreateThread(ThreadSocketHandler, NULL, true); - nThreadSocketHandlerHeartbeat = GetTime(); - } - } } bool StopNode() -- cgit v1.2.3