X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Ffreenetmasterthread.cpp;h=4e7b57085ac51ed864f3560c0dec28a3c9e2ad08;hp=4ca447e1976fc6ba71fcaa9bd16a748b54559c85;hb=107bd97018964d48425306026d06afd038e84db0;hpb=5c0453c8697cfaa843dd7f799e5404733ee56e13 diff --git a/src/freenet/freenetmasterthread.cpp b/src/freenet/freenetmasterthread.cpp index 4ca447e..4e7b570 100644 --- a/src/freenet/freenetmasterthread.cpp +++ b/src/freenet/freenetmasterthread.cpp @@ -20,7 +20,6 @@ #include "../../include/freenet/boardlistrequester.h" #include "../../include/freenet/siteinserter.h" -//#include #include "../../include/pthreadwrapper/thread.h" #ifdef XMEM @@ -171,10 +170,14 @@ void FreenetMasterThread::Run() { DateTime lastreceivedmessage; + DateTime lastconnected; DateTime now; FCPMessage message; bool done=false; + lastconnected.SetToGMTime(); + lastconnected.Add(0,-1); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread started."); Setup(); @@ -183,30 +186,29 @@ void FreenetMasterThread::Run() { if(m_fcp.Connected()==false) { - if(FCPConnect()==false) + // wait at least 1 minute since last successful connect + now.SetToGMTime(); + if(lastconnected<=(now-(1.0/1440.0))) { + if(FCPConnect()==false) + { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::run could not connect to node. Waiting 60 seconds."); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::run could not connect to node. Waiting 60 seconds."); - // wait 60 seconds - will then try to connect again - /* - try - { - ZThread::Thread::sleep(60000); - } - catch(...) - { - done=true; + for(int i=0; i<60 && !IsCancelled(); i++) + { + Sleep(1000); + } } - */ - for(int i=0; i<60 && !IsCancelled(); i++) + else { - Sleep(1000); + lastreceivedmessage.SetToGMTime(); + lastconnected.SetToGMTime(); } } else { - lastreceivedmessage.SetToGMTime(); + Sleep(1000); } } // fcp is connected @@ -241,8 +243,12 @@ void FreenetMasterThread::Run() m_fcp.Disconnect(); } + if(m_fcp.Connected()==false) + { + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::Run Disconnected from Freenet node."); + } + } -// }while(!ZThread::Thread::interrupted() && done==false); }while(!IsCancelled() && done==false); m_fcp.Disconnect();