From 2df31f11d4d56488058a94020ee36e642b889f73 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 27 Jul 1999 20:00:24 +0000 Subject: [PATCH] Removed all references to CC->msglist and CC->num_msgs, and all utility functions which relied upon them. Citadel Is Now Better. --- citadel/ChangeLog | 7 ++-- citadel/citserver.c | 5 --- citadel/room_ops.c | 87 +++++++++---------------------------------- citadel/room_ops.h | 4 -- citadel/serv_expire.c | 42 +++++++++++++++------ citadel/server.h | 3 -- citadel/user_ops.c | 2 + 7 files changed, 53 insertions(+), 97 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index ece60004c..6ab1bc45c 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 1.333 1999/07/27 20:00:24 ajc +Removed all references to CC->msglist and CC->num_msgs, and all utility +functions which relied upon them. Citadel Is Now Better. + Revision 1.332 1999/07/27 19:32:22 ajc Removed serv_upgrade.c and all references to it in Makefile.in Reworked new-mail-count to not use MessageFromList() etc. @@ -1118,6 +1122,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - - - diff --git a/citadel/citserver.c b/citadel/citserver.c index 45d23b95e..e0785b680 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -140,9 +140,6 @@ void cleanup_stuff(void *arg) syslog(LOG_NOTICE,"session %d ended", CC->cs_pid); - /* Deallocate any message list we might have in memory */ - if (CC->msglist != NULL) phree(CC->msglist); - /* Deallocate any user-data attached to this session */ deallocate_user_data(CC); @@ -821,8 +818,6 @@ void *context_loop(struct CitContext *con) CC->upload_fp = NULL; CC->cs_pid = con->client_socket; /* not necessarily portable */ CC->FirstExpressMessage = NULL; - CC->msglist = NULL; - CC->num_msgs = 0; time(&CC->lastcmd); time(&CC->lastidle); strcpy(CC->lastcmdname, " "); diff --git a/citadel/room_ops.c b/citadel/room_ops.c index f208849de..bc93a1314 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -314,43 +314,6 @@ void ForEachRoom(void (*CallBack) (struct quickroom * EachRoom)) } - -/* - * get_msglist() - retrieve room message pointers - */ -void get_msglist(struct quickroom *whichroom) -{ - struct cdbdata *cdbfr; - - if (CC->msglist != NULL) { - phree(CC->msglist); - } - CC->msglist = NULL; - CC->num_msgs = 0; - - cdbfr = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long)); - if (cdbfr == NULL) { - return; - } - CC->msglist = mallok(cdbfr->len); - memcpy(CC->msglist, cdbfr->ptr, cdbfr->len); - CC->num_msgs = cdbfr->len / sizeof(long); - cdb_free(cdbfr); -} - - -/* - * put_msglist() - retrieve room message pointers - */ -void put_msglist(struct quickroom *whichroom) -{ - - if (CC->msglist != NULL) - cdb_store(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long), - CC->msglist, CC->num_msgs * sizeof(long)); -} - - /* * delete_msglist() - delete room message pointers * FIX - this really should check first to make sure there's actually a @@ -419,34 +382,6 @@ long AddMessageToRoom(struct quickroom *whichroom, long newmsgid) } -/* - * MessageFromList() - get a message number from the list currently in memory - */ -long MessageFromList(int whichpos) -{ - - /* Return zero if the position is invalid */ - if (whichpos >= CC->num_msgs) - return 0L; - - return (CC->msglist[whichpos]); -} - -/* - * SetMessageInList() - set a message number in the list currently in memory - */ -void SetMessageInList(int whichpos, long newmsgnum) -{ - - /* Return zero if the position is invalid */ - if (whichpos >= CC->num_msgs) - return; - - CC->msglist[whichpos] = newmsgnum; -} - - - /* * sort message pointers * (returns new msg count) @@ -476,7 +411,7 @@ int sort_msglist(long listptrs[], int oldcount) /* and yank any nulls */ while ((numitems > 0) && (listptrs[0] == 0L)) { memcpy(&listptrs[0], &listptrs[1], - (sizeof(long) * (CC->num_msgs - 1))); + (sizeof(long) * (numitems - 1))); --numitems; } @@ -724,6 +659,9 @@ void usergoto(char *where, int display_result) int newmailcount = 0; struct visit vbuf; char truncated_roomname[ROOMNAMELEN]; + struct cdbdata *cdbfr; + long *msglist = NULL; + int num_msgs = 0; strcpy(CC->quickroom.QRname, where); getroom(&CC->quickroom, where); @@ -747,16 +685,25 @@ void usergoto(char *where, int display_result) info = 1; get_mm(); - get_msglist(&CC->quickroom); - for (a = 0; a < CC->num_msgs; ++a) { - if (MessageFromList(a) > 0L) { + cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->quickroom.QRnumber, sizeof(long)); + if (cdbfr != NULL) { + msglist = mallok(cdbfr->len); + memcpy(msglist, cdbfr->ptr, cdbfr->len); + num_msgs = cdbfr->len / sizeof(long); + cdb_free(cdbfr); + } + + if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) { + if (msglist[a] > 0L) { ++total_messages; - if (MessageFromList(a) > vbuf.v_lastseen) { + if (msglist[a] > vbuf.v_lastseen) { ++new_messages; } } } + if (msglist != NULL) phree(msglist); + if (CC->quickroom.QRflags & QR_MAILBOX) rmailflag = 1; else diff --git a/citadel/room_ops.h b/citadel/room_ops.h index 12431fbd9..4a596ea8e 100644 --- a/citadel/room_ops.h +++ b/citadel/room_ops.h @@ -15,11 +15,7 @@ void getfloor (struct floor *flbuf, int floor_num); void lgetfloor (struct floor *flbuf, int floor_num); void putfloor (struct floor *flbuf, int floor_num); void lputfloor (struct floor *flbuf, int floor_num); -void get_msglist (struct quickroom *whichroom); -void put_msglist (struct quickroom *whichroom); long AddMessageToRoom(struct quickroom *whichroom, long newmsgid); -long int MessageFromList (int whichpos); -void SetMessageInList (int whichpos, long int newmsgnum); int sort_msglist (long int *listptrs, int oldcount); void cmd_lrms (char *argbuf); void cmd_lkra (char *argbuf); diff --git a/citadel/serv_expire.c b/citadel/serv_expire.c index bc93cb924..5bfb0be56 100644 --- a/citadel/serv_expire.c +++ b/citadel/serv_expire.c @@ -115,6 +115,9 @@ void DoPurgeMessages(struct quickroom *qrbuf) { time_t xtime, now; char msgid[64]; int a; + struct cdbdata *cdbfr; + long *msglist = NULL; + int num_msgs = 0; time(&now); GetExpirePolicy(&epbuf, qrbuf); @@ -129,31 +132,38 @@ void DoPurgeMessages(struct quickroom *qrbuf) { if (epbuf.expire_mode == EXPIRE_MANUAL) return; begin_critical_section(S_QUICKROOM); - get_msglist(qrbuf); + cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf->QRnumber, sizeof(long)); + + if (cdbfr != NULL) { + msglist = mallok(cdbfr->len); + memcpy(msglist, cdbfr->ptr, cdbfr->len); + num_msgs = cdbfr->len / sizeof(long); + cdb_free(cdbfr); + } /* Nothing to do if there aren't any messages */ - if (CC->num_msgs == 0) { + if (num_msgs == 0) { end_critical_section(S_QUICKROOM); return; } /* If the room is set to expire by count, do that */ if (epbuf.expire_mode == EXPIRE_NUMMSGS) { - while (CC->num_msgs > epbuf.expire_value) { - delnum = MessageFromList(0); + while (num_msgs > epbuf.expire_value) { + delnum = msglist[0]; lprintf(5, "Expiring message %ld\n", delnum); AdjRefCount(delnum, -1); - memcpy(&CC->msglist[0], &CC->msglist[1], - (sizeof(long)*(CC->num_msgs - 1))); - CC->num_msgs = CC->num_msgs - 1; + memcpy(&msglist[0], &msglist[1], + (sizeof(long)*(num_msgs - 1))); + --num_msgs; ++messages_purged; } } /* If the room is set to expire by age... */ if (epbuf.expire_mode == EXPIRE_AGE) { - for (a=0; a<(CC->num_msgs); ++a) { - delnum = MessageFromList(a); + for (a=0; a (time_t)(epbuf.expire_value * 86400L))) { lprintf(5, "Expiring message %ld\n", delnum); AdjRefCount(delnum, -1); - SetMessageInList(a, 0L); + msglist[a] = 0L; ++messages_purged; } } } - CC->num_msgs = sort_msglist(CC->msglist, CC->num_msgs); - put_msglist(qrbuf); + + if (num_msgs > 0) { + num_msgs = sort_msglist(msglist, num_msgs); + } + + cdb_store(CDB_MSGLISTS, &qrbuf->QRnumber, sizeof(long), + msglist, (num_msgs * sizeof(long)) ); + + if (msglist != NULL) phree(msglist); + end_critical_section(S_QUICKROOM); } diff --git a/citadel/server.h b/citadel/server.h index 4cd091f36..46233912a 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -40,9 +40,6 @@ struct CitContext { struct usersupp usersupp; /* Database record buffers */ struct quickroom quickroom; - long *msglist; - int num_msgs; - char curr_user[32]; /* name of current user */ int logged_in; /* logged in */ int internal_pgm; /* authenticated as internal program */ diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 9904a5823..60dfcc6b3 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -1372,5 +1372,7 @@ int NewMailCount() { } } + if (msglist != NULL) phree(msglist); + return(num_newmsgs); } -- 2.39.2