#include "../../include/freenet/introductionpuzzleinserter.h"\r
#include "../../include/freenet/identityintroductionrequester.h"\r
#include "../../include/freenet/introductionpuzzlerequester.h"\r
-#include "../../include/freenet/introductionpuzzleremover.h"\r
#include "../../include/freenet/identityintroductioninserter.h"\r
#include "../../include/freenet/trustlistinserter.h"\r
#include "../../include/freenet/trustlistrequester.h"\r
+#include "../../include/freenet/messagelistrequester.h"\r
+#include "../../include/freenet/messagerequester.h"\r
+#include "../../include/freenet/messageinserter.h"\r
+#include "../../include/freenet/messagelistinserter.h"\r
+#include "../../include/freenet/periodicdbmaintenance.h"\r
+#include "../../include/freenet/boardlistinserter.h"\r
+#include "../../include/freenet/boardlistrequester.h"\r
\r
-#include <zthread/Thread.h>\r
+//#include <zthread/Thread.h>\r
+#include "../../include/pthreadwrapper/thread.h"\r
\r
#ifdef XMEM\r
#include <xmem.h>\r
{\r
std::string fcpport;\r
\r
- if(Option::instance()->Get("FCPHost",m_fcphost)==false)\r
+ if(Option::Instance()->Get("FCPHost",m_fcphost)==false)\r
{\r
m_fcphost="localhost";\r
- Option::instance()->Set("FCPHost",m_fcphost);\r
+ Option::Instance()->Set("FCPHost",m_fcphost);\r
}\r
- if(Option::instance()->Get("FCPPort",fcpport)==false)\r
+ if(Option::Instance()->Get("FCPPort",fcpport)==false)\r
{\r
fcpport="9481";\r
- Option::instance()->Set("FCPPort",fcpport);\r
+ Option::Instance()->Set("FCPPort",fcpport);\r
}\r
\r
// convert fcp port to long, and make sure it's within the valid port range\r
if(StringFunctions::Convert(fcpport,m_fcpport)==false)\r
{\r
m_fcpport=9481;\r
- Option::instance()->Set("FCPPort","9481");\r
+ Option::Instance()->Set("FCPPort","9481");\r
}\r
\r
m_receivednodehello=false;\r
m_processors.push_back(obj);\r
}\r
\r
-void FreenetMasterThread::run()\r
+void FreenetMasterThread::Run()\r
{\r
\r
+ DateTime lastreceivedmessage;\r
+ DateTime now;\r
FCPMessage message;\r
bool done=false;\r
\r
+ m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread started.");\r
+\r
Setup();\r
\r
do\r
m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::run could not connect to node. Waiting 60 seconds.");\r
\r
// wait 60 seconds - will then try to connect again\r
+ /*\r
try\r
{\r
ZThread::Thread::sleep(60000);\r
{\r
done=true;\r
}\r
+ */\r
+ for(int i=0; i<60 && !IsCancelled(); i++)\r
+ {\r
+ Sleep(1000);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ lastreceivedmessage.SetToGMTime();\r
}\r
}\r
// fcp is connected\r
if(message.GetName()!="")\r
{\r
HandleMessage(message);\r
+ lastreceivedmessage.SetToGMTime();\r
}\r
}\r
\r
(*i)->Process();\r
}\r
\r
+ // if we haven't received any messages from the node in 10 minutes, something is wrong\r
+ now.SetToGMTime();\r
+ if(lastreceivedmessage<(now-(1.0/144.0)))\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::Run The Freenet node has not responded in 10 minutes. Trying to reconnect.");\r
+ m_fcp.Disconnect();\r
+ }\r
+\r
}\r
- }while(!ZThread::Thread::interrupted() && done==false);\r
+// }while(!ZThread::Thread::interrupted() && done==false);\r
+ }while(!IsCancelled() && done==false);\r
\r
m_fcp.Disconnect();\r
\r
Shutdown();\r
\r
+ m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread exiting.");\r
+\r
}\r
\r
void FreenetMasterThread::Setup()\r
m_registrables.push_back(new IntroductionPuzzleInserter(&m_fcp));\r
m_registrables.push_back(new IdentityIntroductionRequester(&m_fcp));\r
m_registrables.push_back(new IntroductionPuzzleRequester(&m_fcp));\r
- m_registrables.push_back(new IntroductionPuzzleRemover());\r
m_registrables.push_back(new IdentityIntroductionInserter(&m_fcp));\r
m_registrables.push_back(new TrustListInserter(&m_fcp));\r
m_registrables.push_back(new TrustListRequester(&m_fcp));\r
+ m_registrables.push_back(new MessageListInserter(&m_fcp));\r
+ m_registrables.push_back(new MessageListRequester(&m_fcp));\r
+ m_registrables.push_back(new MessageRequester(&m_fcp));\r
+ m_registrables.push_back(new MessageInserter(&m_fcp));\r
+ m_registrables.push_back(new BoardListInserter(&m_fcp));\r
+ m_registrables.push_back(new BoardListRequester(&m_fcp));\r
+ m_registrables.push_back(new PeriodicDBMaintenance());\r
\r
for(std::vector<IFreenetRegistrable *>::iterator i=m_registrables.begin(); i!=m_registrables.end(); i++)\r
{\r