Browse Source

hashlog: fix erase while iterating exception

2upstream
Tanguy Pruvot 10 years ago
parent
commit
9bf927a496
  1. 8
      hashlog.cpp

8
hashlog.cpp

@ -164,9 +164,9 @@ extern "C" void hashlog_purge_job(char* jobid)
while (i != tlastshares.end()) { while (i != tlastshares.end()) {
if ((keypfx & i->first) == keypfx) { if ((keypfx & i->first) == keypfx) {
deleted++; deleted++;
tlastshares.erase(i); tlastshares.erase(i++);
} }
i++; else ++i;
} }
if (opt_debug && deleted) { if (opt_debug && deleted) {
applog(LOG_DEBUG, "hashlog: purge job %s, del %d/%d", jobid, deleted, sz); applog(LOG_DEBUG, "hashlog: purge job %s, del %d/%d", jobid, deleted, sz);
@ -185,9 +185,9 @@ extern "C" void hashlog_purge_old(void)
while (i != tlastshares.end()) { while (i != tlastshares.end()) {
if ((now - i->second.tm_sent) > LOG_PURGE_TIMEOUT) { if ((now - i->second.tm_sent) > LOG_PURGE_TIMEOUT) {
deleted++; deleted++;
tlastshares.erase(i); tlastshares.erase(i++);
} }
i++; else ++i;
} }
if (opt_debug && deleted) { if (opt_debug && deleted) {
applog(LOG_DEBUG, "hashlog: %d/%d purged", deleted, sz); applog(LOG_DEBUG, "hashlog: %d/%d purged", deleted, sz);

Loading…
Cancel
Save