X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fidentityinserter.cpp;h=988aa25ca1d49b7ccc7563d3ba2481b4b9dedda7;hp=85fe2f4ef10f291c6a3a6656cb34b4b48f5b9cd6;hb=HEAD;hpb=ed0732b2550c23c05fc9faf925620e87ee6dee12 diff --git a/src/freenet/identityinserter.cpp b/src/freenet/identityinserter.cpp index 85fe2f4..988aa25 100644 --- a/src/freenet/identityinserter.cpp +++ b/src/freenet/identityinserter.cpp @@ -64,6 +64,7 @@ const bool IdentityInserter::HandleMessage(FCPv2::Message &message) std::vector idparts; StringFunctions::Split(message["Identifier"],"|",idparts); + m_lastreceivedmessage=now; // no action for URIGenerated if(message.GetName()=="URIGenerated") @@ -79,15 +80,15 @@ const bool IdentityInserter::HandleMessage(FCPv2::Message &message) if(message.GetName()=="PutSuccessful") { - // a little hack here - if we just inserted index yesterday and it is now the next day - we would have inserted todays date not yesterdays as LastInsertedIdentity. - // If this is the case, we will skip updating LastInsertedIdentity so that we can insert this identity again for today - Poco::DateTime lastdate; - int tzdiff=0; - Poco::DateTimeParser::tryParse("%Y-%m-%d",idparts[4],lastdate,tzdiff); // do check to make sure this is the non-editioned SSK - we ignore failure/success for editioned SSK for now if(message["Identifier"].find(".xml")!=std::string::npos) { + // a little hack here - if we just inserted index yesterday and it is now the next day - we would have inserted todays date not yesterdays as LastInsertedIdentity. + // If this is the case, we will skip updating LastInsertedIdentity so that we can insert this identity again for today + Poco::DateTime lastdate; + int tzdiff=0; + Poco::DateTimeParser::tryParse("%Y-%m-%d",idparts[4],lastdate,tzdiff); if(lastdate.day()==now.day()) { m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false', LastInsertedIdentity='"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";"); @@ -137,6 +138,7 @@ const bool IdentityInserter::HandleMessage(FCPv2::Message &message) void IdentityInserter::Initialize() { m_lastchecked=Poco::Timestamp(); + m_lastreceivedmessage=Poco::Timestamp(); } void IdentityInserter::Process() @@ -149,6 +151,17 @@ void IdentityInserter::Process() m_lastchecked=now; } + if(m_lastreceivedmessage<(now-Poco::Timespan(0,0,10,0,0))) + { + SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE InsertingIdentity='true';"); + st.Step(); + if(st.RowReturned()) + { + m_log->debug("IdentityInserter::Process 10 minutes have passed without an insert response from the node. Restarting inserts."); + m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false';"); + } + } + } void IdentityInserter::RegisterWithThread(FreenetMasterThread *thread) @@ -255,7 +268,7 @@ void IdentityInserter::StartInsert(const long localidentityid) // test insert as editioned SSK mess.Clear(); mess.SetName("ClientPut"); - mess["URI"]=privatekey+messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|Identity|-"+indexstr; + mess["URI"]=privatekey+messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|Identity-"+indexstr; mess["Identifier"]="IdentityInserter|"+mess["URI"]; mess["UploadFrom"]="direct"; mess["DataLength"]=datasizestr;