X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Ffreenetmasterthread.cpp;h=4ca447e1976fc6ba71fcaa9bd16a748b54559c85;hb=8a0a83a78390f22f99d4487cda2569909dfbc28e;hp=689641fd8575d888e2a03ce5899a95998b269a37;hpb=6b896a9e1dc143bba86795be1e9336549db9b85f;p=fms.git diff --git a/src/freenet/freenetmasterthread.cpp b/src/freenet/freenetmasterthread.cpp index 689641f..4ca447e 100644 --- a/src/freenet/freenetmasterthread.cpp +++ b/src/freenet/freenetmasterthread.cpp @@ -8,7 +8,6 @@ #include "../../include/freenet/introductionpuzzleinserter.h" #include "../../include/freenet/identityintroductionrequester.h" #include "../../include/freenet/introductionpuzzlerequester.h" -#include "../../include/freenet/introductionpuzzleremover.h" #include "../../include/freenet/identityintroductioninserter.h" #include "../../include/freenet/trustlistinserter.h" #include "../../include/freenet/trustlistrequester.h" @@ -16,8 +15,13 @@ #include "../../include/freenet/messagerequester.h" #include "../../include/freenet/messageinserter.h" #include "../../include/freenet/messagelistinserter.h" +#include "../../include/freenet/periodicdbmaintenance.h" +#include "../../include/freenet/boardlistinserter.h" +#include "../../include/freenet/boardlistrequester.h" +#include "../../include/freenet/siteinserter.h" -#include +//#include +#include "../../include/pthreadwrapper/thread.h" #ifdef XMEM #include @@ -27,22 +31,22 @@ FreenetMasterThread::FreenetMasterThread() { std::string fcpport; - if(Option::instance()->Get("FCPHost",m_fcphost)==false) + if(Option::Instance()->Get("FCPHost",m_fcphost)==false) { m_fcphost="localhost"; - Option::instance()->Set("FCPHost",m_fcphost); + Option::Instance()->Set("FCPHost",m_fcphost); } - if(Option::instance()->Get("FCPPort",fcpport)==false) + if(Option::Instance()->Get("FCPPort",fcpport)==false) { fcpport="9481"; - Option::instance()->Set("FCPPort",fcpport); + Option::Instance()->Set("FCPPort",fcpport); } // convert fcp port to long, and make sure it's within the valid port range if(StringFunctions::Convert(fcpport,m_fcpport)==false) { m_fcpport=9481; - Option::instance()->Set("FCPPort","9481"); + Option::Instance()->Set("FCPPort","9481"); } m_receivednodehello=false; @@ -163,12 +167,16 @@ void FreenetMasterThread::RegisterPeriodicProcessor(IPeriodicProcessor *obj) m_processors.push_back(obj); } -void FreenetMasterThread::run() +void FreenetMasterThread::Run() { + DateTime lastreceivedmessage; + DateTime now; FCPMessage message; bool done=false; + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread started."); + Setup(); do @@ -181,6 +189,7 @@ void FreenetMasterThread::run() 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); @@ -189,6 +198,15 @@ void FreenetMasterThread::run() { done=true; } + */ + for(int i=0; i<60 && !IsCancelled(); i++) + { + Sleep(1000); + } + } + else + { + lastreceivedmessage.SetToGMTime(); } } // fcp is connected @@ -205,6 +223,7 @@ void FreenetMasterThread::run() if(message.GetName()!="") { HandleMessage(message); + lastreceivedmessage.SetToGMTime(); } } @@ -214,13 +233,24 @@ void FreenetMasterThread::run() (*i)->Process(); } + // if we haven't received any messages from the node in 10 minutes, something is wrong + now.SetToGMTime(); + if(lastreceivedmessage<(now-(1.0/144.0))) + { + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::Run The Freenet node has not responded in 10 minutes. Trying to reconnect."); + m_fcp.Disconnect(); + } + } - }while(!ZThread::Thread::interrupted() && done==false); +// }while(!ZThread::Thread::interrupted() && done==false); + }while(!IsCancelled() && done==false); m_fcp.Disconnect(); Shutdown(); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread exiting."); + } void FreenetMasterThread::Setup() @@ -235,14 +265,17 @@ void FreenetMasterThread::Setup() m_registrables.push_back(new IntroductionPuzzleInserter(&m_fcp)); m_registrables.push_back(new IdentityIntroductionRequester(&m_fcp)); m_registrables.push_back(new IntroductionPuzzleRequester(&m_fcp)); - m_registrables.push_back(new IntroductionPuzzleRemover()); m_registrables.push_back(new IdentityIntroductionInserter(&m_fcp)); m_registrables.push_back(new TrustListInserter(&m_fcp)); m_registrables.push_back(new TrustListRequester(&m_fcp)); + m_registrables.push_back(new MessageListInserter(&m_fcp)); m_registrables.push_back(new MessageListRequester(&m_fcp)); m_registrables.push_back(new MessageRequester(&m_fcp)); m_registrables.push_back(new MessageInserter(&m_fcp)); - m_registrables.push_back(new MessageListInserter(&m_fcp)); + 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 PeriodicDBMaintenance()); for(std::vector::iterator i=m_registrables.begin(); i!=m_registrables.end(); i++) {