From 61ced2537ea36d1ff269e4695c6bee4f45f06dc4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 21 Feb 2007 18:40:57 +0000 Subject: [PATCH] * Removed the completely redunant function get_mm() * get_control() now only fetches the control record from disk if it is not already in memory. --- citadel/control.c | 9 +++++++++ citadel/msgbase.c | 17 ----------------- citadel/msgbase.h | 1 - citadel/room_ops.c | 1 - 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/citadel/control.c b/citadel/control.c index fe596d41a..5ef54287a 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -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; } /* diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 255672e97..74a2f898f 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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); diff --git a/citadel/msgbase.h b/citadel/msgbase.h index 026908fa3..d8a3697ee 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -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); diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 9a2a11ad0..8174dc978 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -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; -- 2.30.2