// Free List Reconstruction Task routine. // void dispatch_FreeListReconstruction(void *pUnused, int iUnused) { UNUSED_PARAMETER(pUnused); UNUSED_PARAMETER(iUnused); if (mudconf.control_flags & CF_DBCHECK) { const char *cmdsave = mudstate.debug_cmd; mudstate.debug_cmd = (char *)"< dbck >"; do_dbck(NOTHING, NOTHING, NOTHING, 0); Guest.CleanUp(); pcache_trim(); pool_reset(); mudstate.debug_cmd = cmdsave; } // Schedule ourselves again. // CLinearTimeAbsolute ltaNow; ltaNow.GetUTC(); CLinearTimeDelta ltd; ltd.SetSeconds(mudconf.check_interval); mudstate.check_counter = ltaNow + ltd; scheduler.DeferTask(mudstate.check_counter, PRIORITY_SYSTEM, dispatch_FreeListReconstruction, 0, 0); }
void NDECL(dispatch) { char *cmdsave; cmdsave = mudstate.debug_cmd; mudstate.debug_cmd = (char *)"< dispatch >"; /* this routine can be used to poll from interface.c */ if (!mudstate.alarm_triggered) return; mudstate.alarm_triggered = 0; mudstate.lastnowmsec = mudstate.nowmsec; mudstate.lastnow = mudstate.now; mudstate.nowmsec = time_ng(NULL); mudstate.now = (time_t) floor(mudstate.nowmsec); do_second(); local_second(); /* Free list reconstruction */ if ((mudconf.control_flags & CF_DBCHECK) && (mudstate.check_counter <= mudstate.nowmsec)) { mudstate.check_counter = mudconf.check_interval + mudstate.nowmsec; mudstate.debug_cmd = (char *)"< dbck >"; cache_reset(0); do_dbck (NOTHING, NOTHING, 0); cache_reset(0); pcache_trim(); } /* Database dump routines */ if ((mudconf.control_flags & CF_CHECKPOINT) && (mudstate.dump_counter <= mudstate.nowmsec)) { mudstate.dump_counter = mudconf.dump_interval + mudstate.nowmsec; mudstate.debug_cmd = (char *)"< dump >"; fork_and_dump(0, (char *)NULL); } /* Idle user check */ if ((mudconf.control_flags & CF_IDLECHECK) && (mudstate.idle_counter <= mudstate.nowmsec)) { mudstate.idle_counter = mudconf.idle_interval + mudstate.nowmsec; mudstate.debug_cmd = (char *)"< idlecheck >"; cache_reset(0); check_idle(); } #ifdef HAVE_GETRUSAGE /* Memory use stats */ if (mudstate.mstats_counter <= mudstate.nowmsec) { int curr; mudstate.mstats_counter = 15 + mudstate.nowmsec; curr = mudstate.mstat_curr; if ( (curr >= 0 ) && (mudstate.now > mudstate.mstat_secs[curr]) ) { struct rusage usage; curr = 1-curr; getrusage(RUSAGE_SELF, &usage); mudstate.mstat_ixrss[curr] = usage.ru_ixrss; mudstate.mstat_idrss[curr] = usage.ru_idrss; mudstate.mstat_isrss[curr] = usage.ru_isrss; mudstate.mstat_secs[curr] = mudstate.now; mudstate.mstat_curr = curr; } } #endif #ifdef RWHO_IN_USE if ((mudconf.control_flags & CF_RWHO_XMIT) && (mudstate.rwho_counter <= mudstate.nowmsec)) { mudstate.rwho_counter = mudconf.rwho_interval + mudstate.nowmsec; mudstate.debug_cmd = (char *)"< rwho update >"; rwho_update(); } #endif /* reset alarm */ alarm_msec (next_timer()); mudstate.debug_cmd = cmdsave; }