From: Art Cancro Date: Sun, 12 Jul 1998 20:34:10 +0000 (+0000) Subject: Finished all of the code relating to the "global server info" stuff defined X-Git-Tag: v7.86~8445 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=0cabe9fe1fa60973f5bf6ea4b09a9e9257d05109 Finished all of the code relating to the "global server info" stuff defined in control.c. The file "citadel.control" is the file that used to be called "MMstructure", and "struct CitControl" used to be "struct msgmain". Also, the user number is now called "usernum" rather than "eternal", and the highest existing user number is now stored in citadel.control rather than in its own file. --- diff --git a/citadel/citserver.c b/citadel/citserver.c index 94de0e6eb..bdd477b89 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -49,10 +49,22 @@ void rec_log(unsigned int lrtype, char *name) end_critical_section(S_CALLLOG); } + +/* + * Various things that need to be initialized at startup + */ +void master_startup() { + lprintf(7, "Opening databases\n"); + open_databases(); + + lprintf(7, "Checking floor reference counts\n"); + check_ref_counts(); + } + /* * Cleanup routine to be called when the server is shutting down. */ -void master_cleanup(void) { +void master_cleanup() { /* Cancel all running sessions */ lprintf(7, "Cancelling running sessions...\n"); @@ -60,6 +72,10 @@ void master_cleanup(void) { kill_session(ContextList->cs_pid); } + /* Close databases */ + lprintf(7, "Closing databases\n"); + close_databases(); + /* Do system-dependent stuff */ sysdep_master_cleanup(); diff --git a/citadel/control.c b/citadel/control.c index 4dec1f0fa..0dd60f013 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -49,6 +49,7 @@ void put_control() { fp = fopen("citadel.control", "wb"); if (fp != NULL) { fwrite(&CitControl, sizeof(struct CitControl), 1, fp); + fclose(fp); } } diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 159169e68..e1c15e492 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -40,7 +40,7 @@ void terminate_idle_sessions(void) { /* - * Main housekeeping function. + * Main housekeeping function. This gets run whenever a session terminates. */ void do_housekeeping() { @@ -63,3 +63,31 @@ void do_housekeeping() { } + +/* + * Check (and fix) floor reference counts. This doesn't need to be done + * very often, since the counts should remain correct during normal operation. + */ +void check_ref_counts() { + int ref[MAXFLOORS]; + struct quickroom qrbuf; + struct floor flbuf; + int a; + + for (a=0; a 0) flbuf.f_flags = flbuf.f_flags | QR_INUSE ; + lputfloor(&flbuf, a); + } + } + diff --git a/citadel/setup.c b/citadel/setup.c index ee16f00cf..16ab9a9b6 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -1,6 +1,6 @@ /* * Citadel/UX setup program - * v3.3 / by Art Cancro + * v4.0 / by Art Cancro * see copyright.txt for copyright information * * *** YOU MUST EDIT sysconfig.h >BEFORE< COMPILING SETUP *** @@ -553,97 +553,6 @@ long cmax; { } -void cre8floors() { - int a,main_ref_count; - FILE *fp; - struct quickroom quickroom; - struct floor floor_rec; - - /* - * first, put all existing rooms on floor 0 (the main floor) and - * count the room records that are in use so we can set the main - * floor's reference count - */ - main_ref_count = 0; - fp = fopen("quickroom", "rb+"); - for (a=0; a"); if (strlen(config.c_twitroom)==0) strcpy(config.c_twitroom,"Trashcan"); if (strlen(config.c_bucket_dir)==0) strcpy(config.c_bucket_dir,"bitbucket"); - if (config.c_msgbase == 0L) - config.c_msgbase = 2000000; if (strlen(config.c_net_password)==0) strcpy(config.c_net_password,"netpassword"); if (config.c_port_number == 0) { @@ -1224,7 +1129,6 @@ NEW_INST: write_config_to_disk(); system("mkdir info 2>/dev/null"); /* Create these */ - system("mkdir rooms 2>/dev/null"); system("mkdir bio 2>/dev/null"); system("mkdir userpics 2>/dev/null"); system("mkdir messages 2>/dev/null"); @@ -1251,7 +1155,6 @@ NEW_INST: if (yesno_s("Create call log?")==1) cre8clog(); } - check_ref_counts(); /* Check reference counts */ check_services_entry(); /* Check /etc/services */ check_inittab_entry(); /* Check /etc/inittab */ diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index 49eb103fc..375439b9f 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -19,7 +19,7 @@ * your system, define CHATLOG to the filename to be saved to. Otherwise, * set CHATLOG to "/dev/null". */ -#define CHATLOG "./chat.log" +#define CHATLOG "/dev/null" /* * SLEEPING refers to the watchdog timer. If a user sits idle without typing diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 8680e2209..fa15477e0 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -430,8 +430,6 @@ int client_gets(char *buf) void sysdep_master_cleanup(void) { lprintf(3, "Closing master socket %d\n", msock); close(msock); - lprintf(7, "Closing databases\n"); - close_databases(); } /* @@ -657,6 +655,9 @@ int main(int argc, char **argv) lprintf(7, "Opening databases\n"); open_databases(); + lprintf(7, "Checking floor reference counts\n"); + check_ref_counts(); + /* * Bind the server to our favourite port. * There is no need to check for errors, because ig_tcp_server()