mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
cleanup,
catch some recoverable exceptions and continue -- version 0.3.12 release git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@148 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
53
net.cpp
53
net.cpp
@@ -25,7 +25,6 @@ CNode* pnodeLocalHost = NULL;
|
||||
uint64 nLocalHostNonce = 0;
|
||||
array<int, 10> vnThreadsRunning;
|
||||
SOCKET hListenSocket = INVALID_SOCKET;
|
||||
int64 nThreadSocketHandlerHeartbeat = INT64_MAX;
|
||||
|
||||
vector<CNode*> 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()
|
||||
|
||||
Reference in New Issue
Block a user