X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Ffreenetmasterthread.cpp;h=a6445addcadd883401c8b8ae27634145f5b4454c;hb=44f964d9b2b2d55a5b5672e9297717bd25fa8ee2;hp=4ca447e1976fc6ba71fcaa9bd16a748b54559c85;hpb=8a0a83a78390f22f99d4487cda2569909dfbc28e;p=fms.git diff --git a/src/freenet/freenetmasterthread.cpp b/src/freenet/freenetmasterthread.cpp index 4ca447e..a6445ad 100644 --- a/src/freenet/freenetmasterthread.cpp +++ b/src/freenet/freenetmasterthread.cpp @@ -19,10 +19,11 @@ #include "../../include/freenet/boardlistinserter.h" #include "../../include/freenet/boardlistrequester.h" #include "../../include/freenet/siteinserter.h" - -//#include +#include "../../include/freenet/fileinserter.h" #include "../../include/pthreadwrapper/thread.h" +#include + #ifdef XMEM #include #endif @@ -171,10 +172,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 +188,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); + for(int i=0; i<60 && !IsCancelled(); i++) + { + Sleep(1000); + } } - catch(...) + else { - done=true; - } - */ - for(int i=0; i<60 && !IsCancelled(); i++) - { - Sleep(1000); + lastreceivedmessage.SetToGMTime(); + lastconnected.SetToGMTime(); } } else { - lastreceivedmessage.SetToGMTime(); + Sleep(1000); } } // fcp is connected @@ -241,8 +245,12 @@ void FreenetMasterThread::Run() m_fcp.Disconnect(); } + if(m_fcp.Connected()==false) + { + m_log->WriteLog(LogFile::LOGLEVEL_INFO,"FreenetMasterThread::Run Disconnected from Freenet node."); + } + } -// }while(!ZThread::Thread::interrupted() && done==false); }while(!IsCancelled() && done==false); m_fcp.Disconnect(); @@ -275,6 +283,7 @@ void FreenetMasterThread::Setup() m_registrables.push_back(new BoardListInserter(&m_fcp)); m_registrables.push_back(new BoardListRequester(&m_fcp)); m_registrables.push_back(new SiteInserter(&m_fcp)); + m_registrables.push_back(new FileInserter(&m_fcp)); m_registrables.push_back(new PeriodicDBMaintenance()); for(std::vector::iterator i=m_registrables.begin(); i!=m_registrables.end(); i++)