Example #1
0
/**
 * Checks cleanup time and performs cleanup if needed
 *
 * Most of this stuff is done at the period DB dump time.  This is
 * separate so it can be run more often for machines with memory
 * constraints.
 *
 *   - purge_for_pool @see purge_for_pool
 *   - free_unused_programs (if tp_period_program_purge)
 *     @see free_unused_programs
 *   - dispose_all_oldprops (if DISKBASE) @see dispose_all_oldprops
 *
 * @private
 */
static void
check_clean_time(void)
{
    time_t currtime = (time_t) time((time_t *) NULL);

    /*
     * @TODO Total overlap with next_clean_time -- use that to
     * calculate if we need to clean or not.
     */
    if (!last_clean_time)
        last_clean_time = (time_t) time((time_t *) NULL);

    if ((last_clean_time + tp_clean_interval) < currtime) {
        last_clean_time = currtime;
        purge_for_pool();

        /*
         * @TODO purge_try_pool() as well?  That is done at dump time but
         *       but not here.  Not sure how much it matters.  Update
         *       the header if you fix this.
         */

        if (tp_periodic_program_purge)
            free_unused_programs();

#ifdef DISKBASE
        dispose_all_oldprops();
#endif
    }
}
Example #2
0
void
check_clean_time (void)
{
    time_t currtime = time((time_t *) NULL);

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

    if ((last_clean_time + tp_clean_interval) < currtime) {
	last_clean_time = currtime;
	add_property((dbref)0, "~sys/lastcleantime", NULL, (int)currtime);
	if (tp_periodic_program_purge)
	    free_unused_programs();
#ifdef DISKBASE
	dispose_all_oldprops();
#endif
    }
}
Example #3
0
void
check_clean_time(void)
{
	long currtime = (long) time((time_t *) NULL);

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

	if ((last_clean_time + tp_clean_interval) < currtime) {
		last_clean_time = currtime;
		purge_for_pool();
		if (tp_periodic_program_purge)
			free_unused_programs();
#ifdef DISKBASE
		dispose_all_oldprops();
#endif
	}
}
Example #4
0
static void 
dump_database_internal(void)
{
    char    tmpfile[2048];
    char    timestring[1024];
    struct tm *timestamp;
    time_t curtime;
    FILE   *f;
   
    curtime = time((time_t *)NULL);
    timestamp = localtime(&curtime); 

    tune_save_parmsfile();

    format_time(timestring, 1024, "%Y.%m.%d", timestamp);

    if (tp_dbdump_warning)
	wall_and_flush(tp_dumping_mesg);

#ifndef KEEPDUMPS
    sprintf(tmpfile, "%s.#%d#", dumpfile, epoch - 1);
    (void) unlink(tmpfile);     /* nuke our predecessor */
#else
/*
    sprintf(tmpfile, "backup/%s.%s.#%d#", dumpfile, timestring, epoch - 1);
 */
    sprintf(tmpfile, "backup/%s.#%d#", dumpfile, epoch - 1);
    (void) rename(dumpfile, tmpfile);
    sprintf(tmpfile, "backup/%s.#%d#", dumpfile, epoch - 10);
    (void) unlink(tmpfile);
#endif

    sprintf(tmpfile, "%s.#%d#", dumpfile, epoch);

    if ((f = fopen(tmpfile, "w")) != NULL) {
	db_write(f);
	fclose(f);
#ifdef WIN32
	if (unlink(dumpfile))
		perror(dumpfile);
#endif
	if (rename(tmpfile, dumpfile) < 0)
	    perror(tmpfile);

#ifdef DISKBASE

#ifdef FLUSHCHANGED
	fclose(input_file);
	free((void *)in_filename);
	in_filename = string_dup(dumpfile);
	if ((input_file = fopen(in_filename, "r")) == NULL)
	    perror(dumpfile);

#ifdef DELTADUMPS
	fclose(delta_outfile);
	if ((delta_outfile = fopen(DELTAFILE_NAME, "w")) == NULL)
	    perror(DELTAFILE_NAME);

	fclose(delta_infile);
	if ((delta_infile = fopen(DELTAFILE_NAME, "r")) == NULL)
	    perror(DELTAFILE_NAME);
#endif
#endif

#endif

    } else {
	perror(tmpfile);
    }

    /* Write out the macros */

    sprintf(tmpfile, "%s.#%d#", MACRO_FILE, epoch - 1);
    (void) unlink(tmpfile);

    sprintf(tmpfile, "%s.#%d#", MACRO_FILE, epoch);

    if ((f = fopen(tmpfile, "w")) != NULL) {
	macrodump(macrotop, f);
	fclose(f);
#ifdef WIN32
	if (unlink(MACRO_FILE))
		perror(MACRO_FILE);
#endif
	if (rename(tmpfile, MACRO_FILE) < 0)
	    perror(tmpfile);
    } else {
	perror(tmpfile);
    }

    if (tp_dbdump_warning)
	wall_and_flush(tp_dumpdone_mesg);
#ifdef DISKBASE
    propcache_hits = 0L;
    propcache_misses = 1L;
#endif

    if (tp_periodic_program_purge)
	free_unused_programs();
#ifdef DISKBASE
    dispose_all_oldprops();
#endif
}