Skip to content
Snippets Groups Projects
Commit 6893c78d authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Log an error upon read failure of dsts.ini and don't write changes back

Part of potential fix (or work-around) for issue #791
parent f4d4eaad
No related branches found
No related tags found
No related merge requests found
...@@ -652,12 +652,15 @@ uint sbbs_t::logonstats() ...@@ -652,12 +652,15 @@ uint sbbs_t::logonstats()
continue; continue;
} }
fread_dstats(dsts, &stats); if(!fread_dstats(dsts, &stats)) {
errormsg(WHERE, ERR_READ, "dsts.ini", i);
} else {
stats.date = time(NULL); stats.date = time(NULL);
fwrite_cstats(csts, &stats); fwrite_cstats(csts, &stats);
fclose_cstats(csts); fclose_cstats(csts);
rolloverstats(&stats); rolloverstats(&stats);
fwrite_dstats(dsts, &stats, __FUNCTION__); fwrite_dstats(dsts, &stats, __FUNCTION__);
}
fclose_dstats(dsts); fclose_dstats(dsts);
} }
} }
...@@ -677,10 +680,13 @@ uint sbbs_t::logonstats() ...@@ -677,10 +680,13 @@ uint sbbs_t::logonstats()
errormsg(WHERE, ERR_OPEN, "dsts.ini", i); errormsg(WHERE, ERR_OPEN, "dsts.ini", i);
return(0L); return(0L);
} }
fread_dstats(fp, &stats); if(!fread_dstats(fp, &stats)) {
errormsg(WHERE, ERR_READ, "dsts.ini", i);
} else {
stats.today.logons++; stats.today.logons++;
stats.total.logons++; stats.total.logons++;
fwrite_dstats(fp, &stats, __FUNCTION__); fwrite_dstats(fp, &stats, __FUNCTION__);
}
fclose_dstats(fp); fclose_dstats(fp);
} }
......
...@@ -4379,7 +4379,9 @@ void sbbs_t::logoffstats() ...@@ -4379,7 +4379,9 @@ void sbbs_t::logoffstats()
FILE* fp = fopen_dstats(&cfg, i ? 0 : cfg.node_num, /* for_write: */true); FILE* fp = fopen_dstats(&cfg, i ? 0 : cfg.node_num, /* for_write: */true);
if(fp == NULL) if(fp == NULL)
continue; continue;
if(fread_dstats(fp, &stats)) { if(!fread_dstats(fp, &stats)) {
errormsg(WHERE, ERR_READ, "dsts.ini", i);
} else {
stats.total.timeon += minutes_used; stats.total.timeon += minutes_used;
stats.today.timeon += minutes_used; stats.today.timeon += minutes_used;
fwrite_dstats(fp, &stats, __FUNCTION__); fwrite_dstats(fp, &stats, __FUNCTION__);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment