X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Ffreenetmasterthread.cpp;h=a9f23917e2d5fef17445a105d8b535d2cba81205;hb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;hp=7a593fc47fd95288c44b71cdb1f4097c987d52f5;hpb=9048d8e482c91960265f29c2b5b3112f2a52f3d8;p=fms.git diff --git a/src/freenet/freenetmasterthread.cpp b/src/freenet/freenetmasterthread.cpp index 7a593fc..a9f2391 100644 --- a/src/freenet/freenetmasterthread.cpp +++ b/src/freenet/freenetmasterthread.cpp @@ -8,12 +8,17 @@ #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" +#include "../../include/freenet/messagelistrequester.h" +#include "../../include/freenet/messagerequester.h" +#include "../../include/freenet/messageinserter.h" +#include "../../include/freenet/messagelistinserter.h" +#include "../../include/freenet/periodicdbmaintenance.h" -#include +//#include +#include "../../include/pthreadwrapper/thread.h" #ifdef XMEM #include @@ -23,22 +28,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; @@ -62,7 +67,7 @@ const bool FreenetMasterThread::FCPConnect() m_receivednodehello=false; } - m_log->WriteLog(LogFile::LOGLEVEL_INFO,__FUNCTION__" trying to connect to node "+m_fcphost); + m_log->WriteLog(LogFile::LOGLEVEL_INFO,"FreenetMasterThread::FCPConnect trying to connect to node "+m_fcphost); if(m_fcp.Connect(m_fcphost.c_str(),m_fcpport)==true) { @@ -71,7 +76,7 @@ const bool FreenetMasterThread::FCPConnect() // send ClientHello message to node m_fcp.SendMessage("ClientHello",2,"Name",clientname.c_str(),"ExpectedVersion","2.0"); - m_log->WriteLog(LogFile::LOGLEVEL_INFO,__FUNCTION__" connected to node"); + m_log->WriteLog(LogFile::LOGLEVEL_INFO,"FreenetMasterThread::FCPConnect connected to node"); return true; } @@ -113,7 +118,7 @@ const bool FreenetMasterThread::HandleMessage(FCPMessage &message) { info+="\t\t\t\t"+(*mi).first+"="+(*mi).second+"\r\n"; } - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" received unhandled "+message.GetName()+" message. Message content :\r\n"+info); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::HandleMessage received unhandled "+message.GetName()+" message. Message content :\r\n"+info); // if unhandled message was alldata - we must retrieve the data if(message.GetName()=="AllData") @@ -138,7 +143,7 @@ const bool FreenetMasterThread::HandleMessage(FCPMessage &message) } else { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,__FUNCTION__" received "+message.GetName()+" message before NodeHello"); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::HandleMessage received "+message.GetName()+" message before NodeHello"); } return false; @@ -159,12 +164,14 @@ void FreenetMasterThread::RegisterPeriodicProcessor(IPeriodicProcessor *obj) m_processors.push_back(obj); } -void FreenetMasterThread::run() +void FreenetMasterThread::Run() { FCPMessage message; bool done=false; + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread started."); + Setup(); do @@ -174,9 +181,10 @@ void FreenetMasterThread::run() if(FCPConnect()==false) { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,__FUNCTION__" 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); @@ -185,6 +193,11 @@ void FreenetMasterThread::run() { done=true; } + */ + for(int i=0; i<60 && !IsCancelled(); i++) + { + Sleep(1000); + } } } // fcp is connected @@ -211,12 +224,15 @@ void FreenetMasterThread::run() } } - }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() @@ -231,10 +247,14 @@ 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 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 PeriodicDBMaintenance()); for(std::vector::iterator i=m_registrables.begin(); i!=m_registrables.end(); i++) {