if (qrbuf->QRnumber > CtdlGetConfigLong("MMnextroom")) {
syslog(LOG_DEBUG, "control: fixing MMnextroom %ld > %ld", qrbuf->QRnumber, CtdlGetConfigLong("MMnextroom"));
- CtdlSetConfigLong("MMnextroom", qrbuf->QRnumber);
+ if (!sanity_diag_mode) {
+ CtdlSetConfigLong("MMnextroom", qrbuf->QRnumber);
+ }
}
CtdlGetRoom(&room, qrbuf->QRname);
for (c=0; c<num_msgs; c++) {
if (msglist[c] > CtdlGetConfigLong("MMhighest")) {
syslog(LOG_DEBUG, "control: fixing MMhighest %ld > %ld", msglist[c], CtdlGetConfigLong("MMhighest"));
- CtdlSetConfigLong("MMhighest", msglist[c]);
+ if (!sanity_diag_mode) {
+ CtdlSetConfigLong("MMhighest", msglist[c]);
+ }
}
}
}
{
if (EachUser->usernum > CtdlGetConfigLong("MMnextuser")) {
syslog(LOG_DEBUG, "control: fixing MMnextuser %ld > %ld", EachUser->usernum, CtdlGetConfigLong("MMnextuser"));
- CtdlSetConfigLong("MMnextuser", EachUser->usernum);
+ if (!sanity_diag_mode) {
+ CtdlSetConfigLong("MMnextuser", EachUser->usernum);
+ }
}
}
syslog(LOG_INFO, "control: sanity checking the recorded highest user number");
ForEachUser(control_find_user, NULL);
syslog(LOG_INFO, "control: sanity checks complete");
+ if (sanity_diag_mode) {
+ syslog(LOG_INFO, "control: sanity check diagnostic mode is active - exiting now");
+ abort();
+ }
}
const char *CitadelServiceUDS="citadel-UDS";
const char *CitadelServiceTCP="citadel-TCP";
void go_threading(void);
+int sanity_diag_mode = 0;
/*
InitializeMasterTSD();
/* parse command-line arguments */
- while ((a=getopt(argc, argv, "l:dh:x:t:B:Dru:")) != EOF) switch(a) {
+ while ((a=getopt(argc, argv, "l:dh:x:t:B:Dru:s")) != EOF) switch(a) {
case 'l':
safestrncpy(facility, optarg, sizeof(facility));
}
break;
+ /* -s tells the server to suppress fixing any discrepancies found during sanity checks, but exit after those checks complete */
+ case 's':
+ sanity_diag_mode = 1;
+ break;
+
default:
/* any other parameter makes it crash and burn */
fprintf(stderr, "citserver: usage: "