From 7259c3e23676752f52f01a63a119b2f44fbc7057 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 12 Oct 1998 03:18:17 +0000 Subject: [PATCH] Built some more of the message expiry infrastructure --- citadel/ChangeLog | 3 +++ citadel/citadel.h | 21 +++++++++++---------- citadel/room_ops.c | 28 +++++++++++++++++++++++++++- citadel/room_ops.h | 1 + citadel/serv_test.c | 16 ++++++++++++++++ citadel/setup.c | 8 ++++++++ citadel/sysdep.c | 4 ++-- 7 files changed, 68 insertions(+), 13 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 05268207a..995cec03b 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,3 +1,6 @@ +Sun Oct 11 23:17:48 EDT 1998 Art Cancro + * Built some more of the message expiry infrastructure + 1998-10-11 Nathan Bryant * citserver.c: fix two more overruns, one of which was preventing the "From Host" from showing up in the ho listing. diff --git a/citadel/citadel.h b/citadel/citadel.h index ae1610b7e..483e7a145 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -30,16 +30,17 @@ typedef unsigned char CIT_UBYTE; #define ROOMNAMELEN 128 /* - * Room policy stuff + * Message expiration policy stuff */ -struct RoomPolicy { - int rp_expire_mode; - long rp_expire_value; +struct ExpirePolicy { + int expire_mode; + long expire_value; }; -#define RP_EXPIRE_NEXTLEVEL 0 /* Inherit expiration policy */ -#define RP_EXPIRE_NUMMSGS 1 /* Keep only latest n messages */ -#define RP_EXPIRE_AGE 2 /* Expire messages by age */ +#define EXPIRE_NEXTLEVEL 0 /* Inherit expiration policy */ +#define EXPIRE_MANUAL 1 /* Don't expire messages at all */ +#define EXPIRE_NUMMSGS 2 /* Keep only latest n messages */ +#define EXPIRE_AGE 3 /* Expire messages by age */ /* @@ -69,7 +70,7 @@ struct config { char c_net_password[20]; /* system net password */ int c_port_number; /* TCP port to run the server on */ int c_ipgm_secret; /* Internal program authentication */ - struct RoomPolicy c_default_rp; /* System default room policy */ + struct ExpirePolicy c_ep; /* System default msg expire policy */ }; #define NODENAME config.c_nodename @@ -139,7 +140,7 @@ struct quickroom { long QRinfo; /* Info file update relative to msgs*/ char QRfloor; /* Which floor this room is on */ time_t QRmtime; /* Date/time of last post */ - struct RoomPolicy QRroompolicy; /* Room policy */ + struct ExpirePolicy QRep; /* Message expiration policy */ }; @@ -189,7 +190,7 @@ struct floor { unsigned short f_flags; /* flags */ char f_name[256]; /* name of floor */ int f_ref_count; /* reference count */ - struct RoomPolicy f_default_rp; /* default room policy */ + struct ExpirePolicy f_ep; /* default expiration policy */ }; #define F_INUSE 1 /* floor is in use */ diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 46700e2f7..fc88de813 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -383,7 +383,6 @@ int sort_msglist(long listptrs[], int oldcount) } - /* * Determine whether a given room is one of the base non-editable rooms */ @@ -393,6 +392,33 @@ int is_noneditable(struct quickroom *qrbuf) { else return(0); } + + +/* + * Retrieve the applicable room policy for a specific room + */ +void GetExpirePolicy(struct ExpirePolicy *epbuf, struct quickroom *qrbuf) { + struct floor flbuf; + + /* If the room has its own policy, return it */ + if (qrbuf->QRep.expire_mode != 0) { + memcpy(epbuf, &qrbuf->QRep, sizeof(struct ExpirePolicy)); + return; + } + + /* Otherwise, if the floor has its own policy, return it */ + getfloor(&flbuf, qrbuf->QRfloor); + if (flbuf.f_ep.expire_mode != 0) { + memcpy(epbuf, &flbuf.f_ep, sizeof(struct ExpirePolicy)); + return; + } + + /* Otherwise, fall back on the system default */ + memcpy(epbuf, &config.c_ep, sizeof(struct ExpirePolicy)); + } + + + /* * cmd_lrms() - List all accessible rooms, known or forgotten */ diff --git a/citadel/room_ops.h b/citadel/room_ops.h index 76514af01..6caffbb33 100644 --- a/citadel/room_ops.h +++ b/citadel/room_ops.h @@ -45,3 +45,4 @@ void cmd_eflr (char *argbuf); void ForEachRoom(void (*CallBack)(struct quickroom *EachRoom)); void assoc_file_name(char *buf, struct quickroom *qrbuf, char *prefix); void delete_room(struct quickroom *qrbuf); +void GetExpirePolicy(struct ExpirePolicy *epbuf, struct quickroom *qrbuf); diff --git a/citadel/serv_test.c b/citadel/serv_test.c index dc7915a59..4ce9e8390 100644 --- a/citadel/serv_test.c +++ b/citadel/serv_test.c @@ -19,6 +19,7 @@ #include "support.h" #include "config.h" #include "dynloader.h" +#include "room_ops.h" extern struct CitContext *ContextList; @@ -67,9 +68,24 @@ void Ygorl(char *username, long usernum) { } + +void DoPurgeMessages(struct quickroom *qrbuf) { + struct ExpirePolicy epbuf; + + GetExpirePolicy(&epbuf, qrbuf); + + lprintf(9, "ExpirePolicy for <%s> is <%d> <%ld>\n", + qrbuf->QRname, epbuf.expire_mode, epbuf.expire_value); + } + +void PurgeMessages(void) { + ForEachRoom(DoPurgeMessages); + } + struct DLModule_Info *Dynamic_Module_Init(void) { CtdlRegisterCleanupHook(CleanupTest); + CtdlRegisterCleanupHook(PurgeMessages); CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM); CtdlRegisterSessionHook(SessionStartTest, EVT_START); CtdlRegisterSessionHook(SessionStopTest, EVT_STOP); diff --git a/citadel/setup.c b/citadel/setup.c index 80f6b18bf..1a09e708e 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -825,6 +825,11 @@ void write_config_to_disk(void) { display_error("setup: cannot open citadel.config"); cleanup(1); } +/******************************************/ +/* THIS IS TEMPORARY FIX FIX FIX FIX FIX */ + config.c_ep.expire_mode = EXPIRE_NUMMSGS; + config.c_ep.expire_value = 10; +/******************************************/ fwrite((char *)&config,sizeof(struct config),1,fp); fclose(fp); } @@ -1023,6 +1028,9 @@ int main(int argc, char *argv[]) { NEW_INST: config.c_setup_level = REV_LEVEL; + +/******************************************/ + write_config_to_disk(); system("mkdir info 2>/dev/null"); /* Create these */ diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 93cfa8e26..4ea3d9b2a 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -115,7 +115,7 @@ void begin_critical_section(int which_one) { int oldval; - lprintf(8, "begin_critical_section(%d)\n", which_one); + /* lprintf(8, "begin_critical_section(%d)\n", which_one); */ /* Don't get interrupted during the critical section */ pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldval); @@ -132,7 +132,7 @@ void end_critical_section(int which_one) { int oldval; - lprintf(8, " end_critical_section(%d)\n", which_one); + /* lprintf(8, " end_critical_section(%d)\n", which_one); */ /* Let go of the semaphore */ pthread_mutex_unlock(&Critters[which_one]); -- 2.39.2