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(); }
/** * Display dump warning, if dump warnings are enabled (tp_dbdump_warning) * * tp_dumpwarn_mesg is the message. * * @private */ static void dump_warning(void) { if (tp_dbdump_warning) { wall_and_flush(tp_dumpwarn_mesg); } }
void dump_warning(void) { if (tp_dbdump_warning) { #ifdef DELTADUMPS if (time_for_monolithic()) { wall_and_flush(tp_dumpwarn_mesg); } else { if (tp_deltadump_warning) { wall_and_flush(tp_deltawarn_mesg); } } #else wall_and_flush(tp_dumpwarn_mesg); #endif } }
void sig_emerg(int i) { wall_and_flush ("\nEmergency signal received ! (power failure ?)\nThe database will be saved.\n"); dump_database(); shutdown_flag = 1; restart_flag = 0; }
RETSIGTYPE sig_emerg(int i) { wall_and_flush("\nEmergency signal received ! (power failure ?)\nThe database will be saved.\n"); dump_database(); shutdown_flag = 1; restart_flag = 0; #if !defined(SYSV) && !defined(_POSIX_VERSION) && !defined(ULTRIX) return 0; #endif }
/** * Handle SIGEMERG * * This will shut down the MUCK and send a wall message to the MUCK. * Database will be dumped as well. * * @param i signal number (ignored) */ void sig_emerg(int i) { /* * @TODO This should probably log_status as well ? */ wall_and_flush ("\nEmergency signal received ! (power failure ?)\nThe database will be saved.\n"); dump_database(); shutdown_flag = 1; restart_flag = 0; }
/* * Named "fork_and_dump()" mostly for historical reasons... */ void fork_and_dump(void) { epoch++; #ifndef DISKBASE if (global_dumper_pid != 0) { wall_wizards("## Dump already in progress. Skipping redundant scheduled dump."); return; } #endif last_monolithic_time = time(NULL); log_status("CHECKPOINTING: %s.#%d#", dumpfile, epoch); if (tp_dbdump_warning) wall_and_flush(tp_dumping_mesg); #ifdef DISKBASE dump_database_internal(); #else # ifndef WIN32 if ((global_dumper_pid=fork())==0) { /* We are the child. */ forked_dump_process_flag = 1; # ifdef NICEVAL /* Requested by snout of SPR, reduce the priority of the * dumper child. */ nice(NICEVAL); # endif /* NICEVAL */ set_dumper_signals(); dump_database_internal(); _exit(0); } if (global_dumper_pid < 0) { global_dumper_pid = 0; wall_wizards("## Could not fork for database dumping. Possibly out of memory."); wall_wizards("## Please restart the server when next convenient."); } # else /* !WIN32 */ dump_database_internal(); /* TODO: This is not thread safe - disabled for now... */ /*global_dumper_pid = (long) _beginthread(fork_dump_thread, 0, 0); if (global_dumper_pid == -1L) { wall_wizards("## Could not create thread for database dumping"); }*/ # endif #endif }
static void dump_database_internal(void) { char tmpfile[2048]; FILE *f; snprintf(tmpfile, sizeof(tmpfile), "%s.#%d#", dumpfile, epoch - 1); (void) unlink(tmpfile); /* nuke our predecessor */ snprintf(tmpfile, sizeof(tmpfile), "%s.#%d#", dumpfile, epoch); if ((f = fopen(tmpfile, "wb")) != NULL) { db_write(f); fclose(f); #ifdef DISKBASE fclose(input_file); #endif #ifdef WIN32 (void) unlink(dumpfile); /* Delete old file before rename */ #endif if (rename(tmpfile, dumpfile) < 0) perror(tmpfile); #ifdef DISKBASE free((void *) in_filename); in_filename = string_dup(dumpfile); if ((input_file = fopen(in_filename, "rb")) == NULL) perror(dumpfile); #endif } else { perror(tmpfile); } /* Write out the macros */ snprintf(tmpfile, sizeof(tmpfile), "%s.#%d#", MACRO_FILE, epoch - 1); (void) unlink(tmpfile); snprintf(tmpfile, sizeof(tmpfile), "%s.#%d#", MACRO_FILE, epoch); if ((f = fopen(tmpfile, "wb")) != NULL) { macrodump(macrotop, f); fclose(f); #ifdef WIN32 unlink(MACRO_FILE); #endif if (rename(tmpfile, MACRO_FILE) < 0) perror(tmpfile); } else { perror(tmpfile); } sync(); #ifdef DISKBASE /* Only show dumpdone mesg if not doing background saves. */ if (tp_dbdump_warning && tp_dumpdone_warning) wall_and_flush(tp_dumpdone_mesg); propcache_hits = 0L; propcache_misses = 1L; #endif }
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 }