Example #1
0
void
check_dump_time(void)
{
	long currtime = (long) time((time_t *) NULL);

	if (!last_dump_time)
		last_dump_time = (long) time((time_t *) NULL);

	if (!dump_warned) {
		if (((last_dump_time + tp_dump_interval) - tp_dump_warntime)
			< currtime) {
			dump_warning();
			dump_warned = 1;
		}
	}

	if ((last_dump_time + tp_dump_interval) < currtime) {
		last_dump_time = currtime;
		add_property((dbref) 0, "_sys/lastdumptime", NULL, (int) currtime);

		if (tp_periodic_program_purge)
			free_unused_programs();
		purge_for_pool();
		purge_try_pool();

#ifdef DELTADUMPS
		dump_deltas();
#else
		fork_and_dump();
#endif

		dump_warned = 0;
	}
}
Example #2
0
void
dump_deltas(void)
{
    if (time_for_monolithic()) {
	fork_and_dump();
	deltas_count = 0;
	return;
    }

    epoch++;
    log_status("DELT: %s.#%d#\n", dumpfile, epoch);

    if (tp_deltadump_warning)
	wall_and_flush(tp_dumpdeltas_mesg);

    db_write_deltas(delta_outfile);

    if (tp_deltadump_warning)
	wall_and_flush(tp_dumpdone_mesg);
#ifdef DISKBASE
    propcache_hits = 0L;
    propcache_misses = 1L;
#endif
    host_save();
}
Example #3
0
/**
 * Do a database dump now
 *
 * This doesn't do any of the purges that the periodic dump does, but
 * it does set the last dump time property.  It also sets the last
 * dump time to now.
 */
void
dump_db_now(void)
{
    time_t currtime = (time_t) time((time_t *) NULL);

    add_property((dbref) 0, SYS_LASTDUMPTIME_PROP, NULL, (int) currtime);
    fork_and_dump();
    last_dump_time = currtime;
    dump_warned = 0;
}
Example #4
0
void
dump_db_now(void)
{
	long currtime = (long) time((time_t *) NULL);

	add_property((dbref) 0, "_sys/lastdumptime", NULL, (int) currtime);
	fork_and_dump();
	last_dump_time = currtime;
	dump_warned = 0;
}
Example #5
0
void
dump_db_now(void)
{
    time_t currtime = time((time_t *) NULL);
    add_property((dbref)0, "~sys/lastdumptime", NULL, (int)currtime);
    fork_and_dump();
    last_dump_time = currtime;
    add_property((dbref)0, "~sys/lastdumpdone", NULL, (int)time((time_t *) NULL));
    dump_warned = 0;
}
Example #6
0
/**
 * Checks if its time to take a dump, among other things.
 *
 * If its time to dump, we also:
 *
 *   * set a last dumped at property
 *   * free unused programs (@see free_unused_programs) if enabled
 *   * purge_for_pool and purge_try_pool
 *     (@see purge_for_pool @see purge_try_pool)
 *
 * The actual dump is fork_and_dump ... @see fork_and_dump
 *
 * @private
 */
static void
check_dump_time(void)
{
    time_t currtime = (time_t) time((time_t *) NULL);

    if (!last_dump_time)
        last_dump_time = (time_t) time((time_t *) NULL);

    /*
     * @TODO There is a lot of overlap here in calculating times
     *       with next_dump_time -- this function should use
     *       next_dump_time instead of having copy-paste versions of
     *       all the code in next_dump_time
     */

    if (!dump_warned) {
        if (((last_dump_time + tp_dump_interval) - tp_dump_warntime)
            < currtime) {
            dump_warning();
            dump_warned = 1;
        }
    }

    if ((last_dump_time + tp_dump_interval) < currtime) {
        last_dump_time = currtime;
        add_property((dbref) 0, SYS_LASTDUMPTIME_PROP, NULL, (int) currtime);

        if (tp_periodic_program_purge)
            free_unused_programs();

        purge_for_pool();
        purge_try_pool();

        fork_and_dump();

        dump_warned = 0;
    }
}
Example #7
0
// Database Dump Task routine.
//
void dispatch_DatabaseDump(void *pUnused, int iUnused)
{
    UNUSED_PARAMETER(pUnused);
    UNUSED_PARAMETER(iUnused);

    int nNextTimeInSeconds = mudconf.dump_interval;

    if (mudconf.control_flags & CF_CHECKPOINT)
    {
        const char *cmdsave = mudstate.debug_cmd;
        mudstate.debug_cmd = (char *)"< dump >";
#ifndef WIN32
        if (mudstate.dumping)
        {
            // There is a dump in progress. These usually happen very quickly.
            // We will reschedule ourselves to try again in 20 seconds.
            // Ordinarily, you would think "...a dump is a dump...", but some
            // dumps might not be the type of dump we're going to do.
            //
            nNextTimeInSeconds = 20;
        }
        else
#endif // !WIN32
        {
            fork_and_dump(0);
        }
        mudstate.debug_cmd = cmdsave;
    }

    // Schedule ourselves again.
    //
    CLinearTimeAbsolute ltaNow;
    ltaNow.GetUTC();
    CLinearTimeDelta ltd;
    ltd.SetSeconds(nNextTimeInSeconds);
    mudstate.dump_counter = ltaNow + ltd;
    scheduler.DeferTask(mudstate.dump_counter, PRIORITY_SYSTEM, dispatch_DatabaseDump, 0, 0);
}
Example #8
0
/** Handle events that may need handling.
 * This routine is polled from bsd.c. At any call, it can handle
 * the HUP and USR1 signals. At calls that are 'on the second',
 * it goes on to perform regular every-second processing and to
 * check whether it's time to do other periodic processes like
 * purge, dump, or inactivity checks.
 */
void
dispatch(void)
{
  static int idle_counter = 0;
  struct module_entry_t *m;
  void (*handle)(void);

  /* A HUP reloads configuration and reopens logs */
  if (hup_triggered) {
    do_rawlog(LT_ERR, T("SIGHUP received: reloading .txt and .cnf files"));
    config_file_startup(NULL, 0);
    config_file_startup(NULL, 1);
    fcache_load(NOTHING);
    help_reindex(NOTHING);
    read_access_file();
    reopen_logs();
    hup_triggered = 0;
  }
  /* A USR1 does a shutdown/reboot */
  if (usr1_triggered) {
    do_reboot(NOTHING, 0);      /* We don't return from this */
    usr1_triggered = 0;         /* But just in case */
  }
  if (!globals.on_second)
    return;
  globals.on_second = 0;

  mudtime = time(NULL);

  do_second();

  migrate_stuff(CHUNK_MIGRATE_AMOUNT);

  if (options.purge_counter <= mudtime) {
    /* Free list reconstruction */
    options.purge_counter = options.purge_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "purge");
    purge();
    strcpy(global_eval_context.ccom, "");
  }

  if (options.dbck_counter <= mudtime) {
    /* Database consistency check */
    options.dbck_counter = options.dbck_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "dbck");
    dbck();
    strcpy(global_eval_context.ccom, "");
  }

  if (idle_counter <= mudtime) {
    /* Inactivity check */
    idle_counter = 30 + mudtime;
    inactivity_check();
  }

  /* Database dump routines */
  if (options.dump_counter <= mudtime) {
    log_mem_check();
    options.dump_counter = options.dump_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "dump");
    fork_and_dump(1);
    strcpy(global_eval_context.ccom, "");
    flag_broadcast(0, "ON-VACATION", "%s",
                   T
                   ("Your ON-VACATION flag is set! If you're back, clear it."));
  } else if (NO_FORK &&
             (options.dump_counter - 60 == mudtime) &&
             *options.dump_warning_1min) {
    flag_broadcast(0, 0, "%s", options.dump_warning_1min);
  } else if (NO_FORK &&
             (options.dump_counter - 300 == mudtime) &&
             *options.dump_warning_5min) {
    flag_broadcast(0, 0, "%s", options.dump_warning_5min);
  }
  if (options.warn_interval && (options.warn_counter <= mudtime)) {
    options.warn_counter = options.warn_interval + mudtime;
    global_eval_context.cplr = NOTHING;
    strcpy(global_eval_context.ccom, "warnings");
    run_topology();
    strcpy(global_eval_context.ccom, "");
  }
#ifdef MUSHCRON
  if((mudtime % 60) == 0)
    run_cron(); /* Run the MUSH Cron Daemon */
#endif /* MUSHCRON */
#ifdef _SWMP_
  sql_timer();
#endif
#ifdef RPMODE_SYS 
  rplog_reset();
#endif

  /* Replacement for local_timer */
  MODULE_ITER(m)
    MODULE_FUNC_NOARGS(handle, m->handle, "module_timer");
}
Example #9
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;
}