maximum backup (2 minutes)

This commit is contained in:
Enno Rehling 2007-02-25 12:58:53 +00:00
parent 546d3a2e1d
commit 523f47eb58
1 changed files with 13 additions and 7 deletions

View File

@ -47,6 +47,7 @@
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -1267,7 +1268,7 @@ prepare_report(faction * f)
int int
write_reports(faction * f, time_t ltime) write_reports(faction * f, time_t ltime)
{ {
int backup = 1; int backup = 1, maxbackup = 128;
boolean gotit = false; boolean gotit = false;
struct report_context ctx; struct report_context ctx;
@ -1298,17 +1299,22 @@ write_reports(faction * f, time_t ltime)
} }
} }
if (errno) {
puts(" ERROR");
sprintf(buf, "Waiting %u seconds before retry", backup);
perror(buf);
sleep(backup);
if (backup<maxbackup) {
backup *= 2;
}
}
else {
puts(" DONE"); puts(" DONE");
}
} while (errno);
if (!gotit) { if (!gotit) {
log_warning(("No report for faction %s!\n", factionid(f))); log_warning(("No report for faction %s!\n", factionid(f)));
} }
if (errno) {
sprintf(buf, "Error writing reports, waiting %u seconds before retry.\n", backup);
perror(buf);
sleep(backup);
backup *= 2;
}
} while (errno);
freelist(ctx.addresses); freelist(ctx.addresses);
seen_done(ctx.seen); seen_done(ctx.seen);
return 0; return 0;