fixed non saving of checkAttempts for pgp signatures of groups, causing pgp signatures of unknown keys to be re-checked every minute (Patch from HM, modified)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7827 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-01-08 19:55:51 +00:00
parent bef921f70c
commit e2af0cb38b

View file

@ -918,22 +918,28 @@ bool SSGxsIdPgp::load(const std::string &input)
{ {
char pgpline[RSGXSID_MAX_SERVICE_STRING]; char pgpline[RSGXSID_MAX_SERVICE_STRING];
int timestamp = 0; int timestamp = 0;
uint32_t attempts = 0;
if (1 == sscanf(input.c_str(), "K:1 I:%[^)]", pgpline)) if (1 == sscanf(input.c_str(), "K:1 I:%[^)]", pgpline))
{ {
idKnown = true; idKnown = true;
std::string str_line = pgpline; std::string str_line = pgpline;
pgpId = RsPgpId(str_line); pgpId = RsPgpId(str_line);
return true;
} }
else if (1 == sscanf(input.c_str(), "K:0 T:%d", &timestamp)) else if (2 == sscanf(input.c_str(), "K:0 T:%d C:%d", &timestamp, &attempts))
{ {
lastCheckTs = timestamp; lastCheckTs = timestamp;
checkAttempts = attempts;
idKnown = false; idKnown = false;
return true;
} }
else else
{ {
lastCheckTs = 0;
checkAttempts = 0;
idKnown = false;
return false; return false;
} }
return true;
} }
std::string SSGxsIdPgp::save() const std::string SSGxsIdPgp::save() const
@ -946,7 +952,7 @@ std::string SSGxsIdPgp::save() const
} }
else else
{ {
rs_sprintf(output, "K:0 T:%d", lastCheckTs); rs_sprintf(output, "K:0 T:%d C:%d", lastCheckTs, checkAttempts);
} }
return output; return output;
} }
@ -2425,15 +2431,20 @@ bool p3IdService::pgphash_handlerequest(uint32_t token)
{ {
wait_period = 30 * SECS_PER_DAY; wait_period = 30 * SECS_PER_DAY;
} }
#ifdef DEBUG_IDS
std::cerr << "p3IdService: group " << *vit << " age=" << age << ", attempts=" << ssdata.pgp.checkAttempts << ", wait period = " << wait_period ;
#endif
if (age < wait_period) if (age < wait_period)
{ {
#ifdef DEBUG_IDS #ifdef DEBUG_IDS
std::cerr << "p3IdService::pgphash_request() discarding Recent Check"; std::cerr << " => discard." << std::endl;
std::cerr << std::endl;
#endif // DEBUG_IDS #endif // DEBUG_IDS
continue; continue;
} }
#ifdef DEBUG_IDS
std::cerr << " => recheck!" << std::endl;
#endif
} }
/* if we get here -> then its to be processed */ /* if we get here -> then its to be processed */