report directory in .ini file

sleep/retry when errno during report writing.
This commit is contained in:
Enno Rehling 2007-02-25 11:10:13 +00:00
parent 602853f0e2
commit 27c188ea1c
3 changed files with 65 additions and 48 deletions

View File

@ -1267,6 +1267,7 @@ prepare_report(faction * f)
int int
write_reports(faction * f, time_t ltime) write_reports(faction * f, time_t ltime)
{ {
int backup = 1;
boolean gotit = false; boolean gotit = false;
report_type * rtype = report_types; report_type * rtype = report_types;
struct report_context ctx; struct report_context ctx;
@ -1281,6 +1282,8 @@ write_reports(faction * f, time_t ltime)
get_seen_interval(&ctx); get_seen_interval(&ctx);
get_addresses(&ctx); get_addresses(&ctx);
do {
errno = 0;
printf("Reports for %s:", factionname(f)); printf("Reports for %s:", factionname(f));
fflush(stdout); fflush(stdout);
@ -1298,7 +1301,13 @@ write_reports(faction * f, time_t ltime)
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;

View File

@ -99,6 +99,7 @@ extern "C" {
# define HAVE_STRNCASECMP # define HAVE_STRNCASECMP
# define HAVE_ACCESS # define HAVE_ACCESS
# define HAVE_STAT # define HAVE_STAT
# define HAVE_SLEEP
typedef struct stat stat_type; typedef struct stat stat_type;
# include <dirent.h> # include <dirent.h>
# define HAVE_READDIR # define HAVE_READDIR
@ -127,6 +128,7 @@ typedef struct stat stat_type;
# define HAVE_STRICMP # define HAVE_STRICMP
# define HAVE_STRNICMP # define HAVE_STRNICMP
# define HAVE_STRDUP # define HAVE_STRDUP
# define HAVE_SLEEP
# define snprintf _snprintf # define snprintf _snprintf
# define HAVE_SNPRINTF # define HAVE_SNPRINTF
# undef HAVE_STRCASECMP # undef HAVE_STRCASECMP
@ -159,6 +161,9 @@ typedef struct _stat stat_type;
# define strdup _strdup # define strdup _strdup
# define HAVE_STRDUP # define HAVE_STRDUP
# define sleep _sleep
# define HAVE_SLEEP
# define stricmp(a, b) _stricmp(a, b) # define stricmp(a, b) _stricmp(a, b)
# define HAVE_STRICMP # define HAVE_STRICMP

View File

@ -573,10 +573,6 @@ load_inifile(const char * filename)
if (d) { if (d) {
const char * str; const char * str;
lomem = iniparser_getint(d, "eressea:lomem", lomem)?1:0;
quiet = iniparser_getint(d, "eressea:verbose", 0)?0:1;
str = iniparser_getstr(d, "eressea:run");
if (str) luafile = str;
str = iniparser_getstr(d, "common:base"); str = iniparser_getstr(d, "common:base");
if (str) g_basedir = str; if (str) g_basedir = str;
str = iniparser_getstr(d, "common:res"); str = iniparser_getstr(d, "common:res");
@ -585,6 +581,13 @@ load_inifile(const char * filename)
if (str) xmlfile = str; if (str) xmlfile = str;
str = iniparser_getstr(d, "common:scripts"); str = iniparser_getstr(d, "common:scripts");
if (str) script_path = str; if (str) script_path = str;
lomem = iniparser_getint(d, "common:lomem", lomem)?1:0;
quiet = iniparser_getint(d, "eressea:verbose", 0)?0:1;
str = iniparser_getstr(d, "eressea:run");
if (str) luafile = str;
str = iniparser_getstr(d, "eressea:report");
if (str) g_reportdir = str;
} }
inifile = d; inifile = d;
} }