Finished all of the code relating to the "global server info" stuff defined
authorArt Cancro <ajc@citadel.org>
Sun, 12 Jul 1998 20:34:10 +0000 (20:34 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 12 Jul 1998 20:34:10 +0000 (20:34 +0000)
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.

citadel/citserver.c
citadel/control.c
citadel/housekeeping.c
citadel/setup.c
citadel/sysconfig.h
citadel/sysdep.c

index 94de0e6eb55fa6c75e7fe30f23868683ef8fa700..bdd477b892a7b33763de9004975d1c902fd2f964 100644 (file)
@@ -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();
 
index 4dec1f0fadd01266e0b13a3ab0a795c4887f0ecb..0dd60f0137d7cc011b94abc1d58017c49b477526 100644 (file)
@@ -49,6 +49,7 @@ void put_control() {
        fp = fopen("citadel.control", "wb");
        if (fp != NULL) {
                fwrite(&CitControl, sizeof(struct CitControl), 1, fp);
+               fclose(fp);
                }
        }
 
index 159169e6833adc880b6598fcffcfe0918794aeb7..e1c15e4924106d231ab1813bc6cc49747dc4d81f 100644 (file)
@@ -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<MAXFLOORS; ++a) ref[a] = 0;
+               
+       for (a=0; a<MAXROOMS; ++a) {
+               getroom(&qrbuf, a);
+               if (qrbuf.QRflags & QR_INUSE) {
+                       ++ref[(int)qrbuf.QRfloor];
+                       }
+               }
+
+       for (a=0; a<MAXFLOORS; ++a) {
+               lgetfloor(&flbuf, a);
+               flbuf.f_ref_count = ref[a];
+               if (ref[a] > 0) flbuf.f_flags = flbuf.f_flags | QR_INUSE ;
+               lputfloor(&flbuf, a);
+               }
+       }       
+
index ee16f00cf7b49c2f580ece3bc321c16443f00083..16ab9a9b64f62b063dd4bbe2708f45ea6150cb69 100644 (file)
@@ -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<MAXROOMS; ++a) {
-               progress("Preparing room files for addition of floors",
-                       (long)a,
-                       (long)MAXROOMS-1);
-               fseek(fp, (a*((long)sizeof(struct quickroom))), 0);
-               fread((char *)&quickroom,sizeof(struct quickroom),1,fp);
-               if (quickroom.QRflags & QR_INUSE) ++main_ref_count;
-               quickroom.QRfloor = 0;
-               fseek(fp, (a*((long)sizeof(struct quickroom))), 0);
-               fwrite((char *)&quickroom,sizeof(struct quickroom),1,fp);
-               }
-       fclose(fp);
-
-       /* Open a new floortab file */
-       fp=fopen("floortab","wb");
-
-       /* Create the main floor */
-       floor_rec.f_flags = (F_INUSE);
-       strcpy(floor_rec.f_name, "Main Floor");
-       floor_rec.f_ref_count = main_ref_count;
-       floor_rec.f_reserved = 0;
-       fwrite((char *)&floor_rec,sizeof(struct floor),1,fp);
-
-
-       /* make the remaining floors blanks */
-       floor_rec.f_flags = 0;
-       strcpy(floor_rec.f_name, "");
-       floor_rec.f_ref_count = 0;
-       floor_rec.f_reserved = 0;
-
-       for (a=1; a<MAXFLOORS; ++a) {
-               progress("Creating floor table (floortab)",
-                       (long)a,
-                       (long)MAXFLOORS-1
-                       );
-               fwrite((char *)&floor_rec,sizeof(struct floor),1,fp);
-               }
-       fclose(fp);
-
-       }
-
-
-/*
- * check (and fix) floor reference counts
- */
-void check_ref_counts() {
-       int ref[MAXFLOORS];
-       int a;
-       FILE *fp;
-       struct quickroom qrbuf;
-       struct floor flbuf;
-
-       for (a=0; a<MAXFLOORS; ++a) ref[a] = 0;
-
-       fp = fopen("quickroom","rb");
-       for (a=0; a<MAXROOMS; ++a) {
-               progress("Checking reference counts - phase 1 of 2",
-                       a,MAXROOMS-1);
-               fread((char *)&qrbuf,sizeof(struct quickroom),1,fp);
-               if (qrbuf.QRflags & QR_INUSE) {
-                       ++ref[(int)qrbuf.QRfloor];
-                       }
-               }
-       fclose(fp);
-
-       fp = fopen("floortab","rb+");
-       for (a=0; a<MAXFLOORS; ++a) {
-               progress("Checking reference counts - phase 2 of 2",
-                       a,MAXFLOORS-1);
-               fseek(fp,(long)a*(long)sizeof(struct floor),0);
-               fread((char *)&flbuf,sizeof(struct floor),1,fp);
-               flbuf.f_ref_count = ref[a];
-               fseek(fp,(long)a*(long)sizeof(struct floor),0);
-               fwrite((char *)&flbuf,sizeof(struct floor),1,fp);
-               }
-       fclose(fp);
-       }       
-
 
 /*
  * check_services_entry()  -- Make sure "citadel" is in /etc/services
@@ -1151,16 +1060,12 @@ void main(int argc, char *argv[]) {
                strcpy(config.c_phonenum,"US 800 555 1212");
        if (config.c_initax == 0)
                config.c_initax = 1;
-       /* if (config.c_regiscall == 0)
-               config.c_regiscall = 1; */
        if (strlen(config.c_moreprompt)==0)
                strcpy(config.c_moreprompt,"<more>");
        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 */
 
index 49eb103fcf32ecb1d85dd40cef32880df4ffdcb4..375439b9f138a057081c036f2a5eeed7081403b0 100644 (file)
@@ -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
index 8680e2209592a1cae6b444a1e1e79d330c01893d..fa15477e0d1cd6a0ba008a4612949626365dacbb 100644 (file)
@@ -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()