X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fmessagerequester.cpp;h=c5361ec47a7f2a02db2f708a5902db9fac6ed4fb;hb=c0ebc7b53a977885ebc2d3a679c586ae20c0bc4a;hp=ea3ec858540aa6220969c8db54c31189f83fef40;hpb=dec33c63afafabf83c3039e916725cac6faef9b3;p=fms.git diff --git a/src/freenet/messagerequester.cpp b/src/freenet/messagerequester.cpp index ea3ec85..c5361ec 100644 --- a/src/freenet/messagerequester.cpp +++ b/src/freenet/messagerequester.cpp @@ -117,7 +117,10 @@ const bool MessageRequester::HandleAllData(FCPMessage &message) // receive the file data.resize(datalength); - m_fcp->ReceiveRaw(&data[0],datalength); + if(data.size()>0) + { + m_fcp->ReceiveRaw(&data[0],datalength); + } // mark this index as received st=m_db->Prepare("UPDATE tblMessageRequests SET Found='true' WHERE IdentityID=? AND Day=? AND RequestIndex=?;"); @@ -128,7 +131,7 @@ const bool MessageRequester::HandleAllData(FCPMessage &message) st.Finalize(); // parse file into xml and update the database - if(xml.ParseXML(std::string(data.begin(),data.end()))==true) + if(data.size()>0 && xml.ParseXML(std::string(data.begin(),data.end()))==true) { std::vector boards=xml.GetBoards(); std::map replyto=xml.GetInReplyTo(); @@ -324,8 +327,9 @@ void MessageRequester::Initialize() { m_fcpuniquename="MessageRequester"; std::string tempval; - Option::Instance()->Get("MaxMessageRequests",tempval); - StringFunctions::Convert(tempval,m_maxrequests); + + m_maxrequests=0; + Option::Instance()->GetInt("MaxMessageRequests",m_maxrequests); if(m_maxrequests<1) { m_maxrequests=1; @@ -335,8 +339,9 @@ void MessageRequester::Initialize() { m_log->warning("Option MaxMessageRequests is currently set at "+tempval+". This value might be incorrectly configured."); } - Option::Instance()->Get("MessageDownloadMaxDaysBackward",tempval); - StringFunctions::Convert(tempval,m_maxdaysbackward); + + m_maxdaysbackward=0; + Option::Instance()->GetInt("MessageDownloadMaxDaysBackward",m_maxdaysbackward); if(m_maxdaysbackward<0) { m_maxdaysbackward=0; @@ -346,8 +351,9 @@ void MessageRequester::Initialize() { m_log->warning("Option MessageDownloadMaxDaysBackward is currently set at "+tempval+". This value might be incorrectly configured."); } - Option::Instance()->Get("MaxPeerMessagesPerDay",tempval); - StringFunctions::Convert(tempval,m_maxpeermessages); + + m_maxpeermessages=0; + Option::Instance()->GetInt("MaxPeerMessagesPerDay",m_maxpeermessages); if(m_maxpeermessages<1) { m_maxpeermessages=1; @@ -357,8 +363,9 @@ void MessageRequester::Initialize() { m_log->warning("Option MaxPeerMessagesPerDay is currently set at "+tempval+". This value might be incorrectly configured. The suggested value is 200."); } - Option::Instance()->Get("MaxBoardsPerMessage",tempval); - StringFunctions::Convert(tempval,m_maxboardspermessage); + + m_maxboardspermessage=0; + Option::Instance()->GetInt("MaxBoardsPerMessage",m_maxboardspermessage); if(m_maxboardspermessage<1) { m_maxboardspermessage=1; @@ -416,7 +423,9 @@ void MessageRequester::PopulateIDList() } sql+="AND tblIdentity.Name <> '' "; // sort by day descending - in case there is a bunch of messages on a day that keep timing out, we will eventually get to the next day and hopefully find messages there - sql+="ORDER BY tblMessageRequests.Day DESC "; + // secondary ascending sort on tries + // tertiary sort on request index (so we get low indexes first) + sql+="ORDER BY tblMessageRequests.Day DESC, tblMessageRequests.Tries ASC, tblMessageRequests.RequestIndex ASC "; sql+=";"; SQLite3DB::Statement st=m_db->Prepare(sql); @@ -502,6 +511,13 @@ void MessageRequester::StartRequest(const std::string &requestid) m_requesting.push_back(requestid); + // update tries + st=m_db->Prepare("UPDATE tblMessageRequests SET Tries=Tries+1 WHERE IdentityID=? AND Day=? AND RequestIndex=?;"); + st.Bind(0,identityid); + st.Bind(1,date); + st.Bind(2,indexstr); + st.Step(); + m_log->debug("MessageRequester::StartRequest requesting "+message["Identifier"]); }