* Removed the completely redunant function get_mm()
authorArt Cancro <ajc@citadel.org>
Wed, 21 Feb 2007 18:40:57 +0000 (18:40 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 21 Feb 2007 18:40:57 +0000 (18:40 +0000)
* get_control() now only fetches the control record from disk if it
  is not already in memory.

citadel/control.c
citadel/msgbase.c
citadel/msgbase.h
citadel/room_ops.c

index fe596d41a5eb636aecbf552c3cd3d47bae009733..5ef54287aee0154d3710c1543d70c5c940f606f3 100644 (file)
@@ -70,6 +70,14 @@ void lock_control(void)
  */
 void get_control(void)
 {
+       static int already_have_control = 0;
+
+       /*
+        * If we already have the control record in memory, there's no point
+        * in reading it from disk again.
+        */
+       if (already_have_control) return;
+
        /* Zero it out.  If the control record on disk is missing or short,
         * the system functions with all control record fields initialized
         * to zero.
@@ -102,6 +110,7 @@ void get_control(void)
 
        rewind(control_fp);
        fread(&CitControl, sizeof(struct CitControl), 1, control_fp);
+       already_have_control = 1;
 }
 
 /*
index 255672e97360fbdefbbf1c5989ea1f40af48ddf8..74a2f898ff31a0ce9616a1ef7aded23d5d682a38 100644 (file)
@@ -243,22 +243,6 @@ int alias(char *name)
 }
 
 
-void get_mm(void)
-{
-       FILE *fp;
-
-       fp = fopen(file_citadel_control, "r");
-       if (fp == NULL) {
-               lprintf(CTDL_CRIT, "Cannot open %s: %s\n",
-                               file_citadel_control,
-                               strerror(errno));
-               exit(errno);
-       }
-       fread((char *) &CitControl, sizeof(struct CitControl), 1, fp);
-       fclose(fp);
-}
-
-
 /*
  * Back end for the MSGS command: output message number only.
  */
@@ -540,7 +524,6 @@ int CtdlForEachMessage(int mode, long ref, char *search_string,
        long *search_msgs = NULL;
 
        /* Learn about the user and room in question */
-       get_mm();
        getuser(&CC->user, CC->curr_user);
        CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
 
index 026908fa381c34da3e55be354a6c0cc2e97a4578..d8a3697ee5a865b3bc33d16bd505b7d2a64442dd 100644 (file)
@@ -78,7 +78,6 @@ struct addresses_to_be_filed {
 extern struct addresses_to_be_filed *atbf;
 
 int alias (char *name);
-void get_mm (void);
 void cmd_msgs (char *cmdbuf);
 void cmd_isme (char *cmdbuf);
 void help_subst (char *strbuf, char *source, char *dest);
index 9a2a11ad039f37dd3bd84ccfe3cdc7c57a66899a..8174dc97833b485950a786a05e1fbf3d99ed2b34 100644 (file)
@@ -847,7 +847,6 @@ void usergoto(char *where, int display_result, int transiently,
                info = 1;
        }
 
-       get_mm();
         cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
         if (cdbfr != NULL) {
                msglist = (long *) cdbfr->ptr;