-void check_control(void)
-{
- syslog(LOG_INFO, "Sanity checking the recorded highest message, user, and room numbers\n");
- CtdlForEachRoom(control_find_highest, NULL);
+void check_control(void) {
+
+ syslog(LOG_INFO, "control: sanity checking the recorded highest message and room numbers");
+ struct cfh cfh;
+ memset(&cfh, 0, sizeof(struct cfh));
+ CtdlForEachRoom(control_find_highest, &cfh);
+
+ if (cfh.highest_roomnum_found > CtdlGetConfigLong("MMnextroom")) {
+ syslog(LOG_DEBUG, "control: fixing MMnextroom %ld > %ld", cfh.highest_roomnum_found, CtdlGetConfigLong("MMnextroom"));
+ if (!sanity_diag_mode) {
+ CtdlSetConfigLong("MMnextroom", cfh.highest_roomnum_found);
+ }
+ }
+
+ if (cfh.highest_msgnum_found > CtdlGetConfigLong("MMhighest")) {
+ syslog(LOG_DEBUG, "control: fixing MMhighest %ld > %ld", cfh.highest_msgnum_found, CtdlGetConfigLong("MMhighest"));
+ if (!sanity_diag_mode) {
+ CtdlSetConfigLong("MMhighest", cfh.highest_msgnum_found);
+ }
+ }
+
+ syslog(LOG_INFO, "control: sanity checking the recorded highest user number");