\r
do\r
{\r
- if(m_fcp.Connected()==false)\r
+ try\r
{\r
- // wait at least 1 minute since last successful connect\r
- now=Poco::Timestamp();\r
- if(lastconnected<=(now-Poco::Timespan(0,0,1,0,0)))\r
+ if(m_fcp.Connected()==false)\r
{\r
- if(FCPConnect()==false)\r
+ // wait at least 1 minute since last successful connect\r
+ now=Poco::Timestamp();\r
+ if(lastconnected<=(now-Poco::Timespan(0,0,1,0,0)))\r
{\r
+ if(FCPConnect()==false)\r
+ {\r
\r
- m_log->error("FreenetMasterThread::run could not connect to node. Waiting 60 seconds.");\r
+ m_log->error("FreenetMasterThread::run could not connect to node. Waiting 60 seconds.");\r
\r
- for(int i=0; i<60 && !IsCancelled(); i++)\r
+ for(int i=0; i<60 && !IsCancelled(); i++)\r
+ {\r
+ Poco::Thread::sleep(1000);\r
+ }\r
+ }\r
+ else\r
{\r
- Poco::Thread::sleep(1000);\r
+ lastreceivedmessage=Poco::Timestamp();\r
+ lastconnected=Poco::Timestamp();\r
}\r
}\r
else\r
{\r
- lastreceivedmessage=Poco::Timestamp();\r
- lastconnected=Poco::Timestamp();\r
+ Poco::Thread::sleep(1000);\r
}\r
}\r
+ // fcp is connected\r
else\r
{\r
- Poco::Thread::sleep(1000);\r
- }\r
- }\r
- // fcp is connected\r
- else\r
- {\r
- m_fcp.Update(1);\r
+ m_fcp.Update(1);\r
\r
- // check for message on receive buffer and handle it\r
- if(m_fcp.ReceiveBufferSize()>0)\r
- {\r
- message.Reset();\r
- message=m_fcp.ReceiveMessage();\r
+ // check for message on receive buffer and handle it\r
+ if(m_fcp.ReceiveBufferSize()>0)\r
+ {\r
+ message.Reset();\r
+ message=m_fcp.ReceiveMessage();\r
\r
- if(message.GetName()!="")\r
+ if(message.GetName()!="")\r
+ {\r
+ HandleMessage(message);\r
+ lastreceivedmessage=Poco::Timestamp();\r
+ }\r
+ }\r
+\r
+ // let objects do their processing\r
+ for(std::vector<IPeriodicProcessor *>::iterator i=m_processors.begin(); i!=m_processors.end(); i++)\r
{\r
- HandleMessage(message);\r
- lastreceivedmessage=Poco::Timestamp();\r
+ (*i)->Process();\r
}\r
- }\r
\r
- // let objects do their processing\r
- for(std::vector<IPeriodicProcessor *>::iterator i=m_processors.begin(); i!=m_processors.end(); i++)\r
- {\r
- (*i)->Process();\r
- }\r
+ // if we haven't received any messages from the node in 10 minutes, something is wrong\r
+ now=Poco::Timestamp();\r
+ if(lastreceivedmessage<(now-Poco::Timespan(0,0,10,0,0)))\r
+ {\r
+ m_log->error("FreenetMasterThread::Run The Freenet node has not responded in 10 minutes. Trying to reconnect.");\r
+ m_fcp.Disconnect();\r
+ }\r
\r
- // if we haven't received any messages from the node in 10 minutes, something is wrong\r
- now=Poco::Timestamp();\r
- if(lastreceivedmessage<(now-Poco::Timespan(0,0,10,0,0)))\r
- {\r
- m_log->error("FreenetMasterThread::Run The Freenet node has not responded in 10 minutes. Trying to reconnect.");\r
- m_fcp.Disconnect();\r
- }\r
+ if(m_fcp.Connected()==false)\r
+ {\r
+ m_log->information("FreenetMasterThread::Run Disconnected from Freenet node.");\r
+ }\r
\r
- if(m_fcp.Connected()==false)\r
- {\r
- m_log->information("FreenetMasterThread::Run Disconnected from Freenet node.");\r
}\r
-\r
+ }\r
+ catch(Poco::Exception &e)\r
+ {\r
+ m_log->error("FreenetMasterThread::run caught exception : "+e.displayText());\r
+ }\r
+ catch(...)\r
+ {\r
+ m_log->error("FreenetMasterThread::run caught unknown exception");\r
}\r
}while(!IsCancelled() && done==false);\r
\r