From: Art Cancro Date: Sat, 23 Sep 2006 03:02:03 +0000 (+0000) Subject: Completed a new queue (sieve_list) which will instantly X-Git-Tag: v7.86~3935 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=5864d4453d4533cb1988d80ea4e5fa59171e7076 Completed a new queue (sieve_list) which will instantly bring to the attention of the housekeeping thread, any rooms which are inboxes and may require Sieve processing. --- diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 1c833f040..365eeede3 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -43,7 +43,9 @@ #include "msgbase.h" #include "journaling.h" - +#ifdef HAVE_LIBSIEVE +# include "serv_sieve.h" +#endif /* * Terminate idle sessions. This function pounds through the session table @@ -168,6 +170,9 @@ void do_housekeeping(void) { /* First, do the "as often as needed" stuff... */ JournalRunQueue(); +#ifdef HAVE_LIBSIEVE + perform_sieve_processing(); +#endif /* Then, do the "once per minute" stuff... */ if (do_perminute_housekeeping_now) { diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 978b19e9d..b6d6a0bc3 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -54,6 +54,10 @@ #include "citadel_dirs.h" #include "serv_network.h" +#ifdef HAVE_LIBSIEVE +# include "serv_sieve.h" +#endif /* HAVE_LIBSIEVE */ + long config_msgnum; struct addresses_to_be_filed *atbf = NULL; @@ -2036,6 +2040,13 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms /* Submit this room for net processing */ network_queue_room(&CC->room, NULL); +#ifdef HAVE_LIBSIEVE + /* If this is someone's inbox, submit the room for sieve processing */ + if (!strcasecmp(&CC->room.QRname[11], MAILROOM)) { + sieve_queue_room(&CC->room); + } +#endif /* HAVE_LIBSIEVE */ + /* Go back to the room we were in before we wandered here... */ getroom(&CC->room, hold_rm); diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 17dd4ff9e..240cb55dc 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -1650,7 +1650,7 @@ int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr) { } /* Can't delete your Mail> room */ - if (!strcasecmp(&qr->QRname[12], MAILROOM)) return(0); + if (!strcasecmp(&qr->QRname[11], MAILROOM)) return(0); /* Otherwise it's ok */ return(1); diff --git a/citadel/serv_extensions.h b/citadel/serv_extensions.h index f23769149..1868fc335 100644 --- a/citadel/serv_extensions.h +++ b/citadel/serv_extensions.h @@ -36,6 +36,7 @@ char *serv_fulltext_init(void); char *serv_autocompletion_init(void); char *serv_postfix_tcpdict(void); char *serv_managesieve_init(void); +char *serv_sieve_init(void); /* */ diff --git a/citadel/serv_sieve.c b/citadel/serv_sieve.c index e9fca4f50..604a9f891 100644 --- a/citadel/serv_sieve.c +++ b/citadel/serv_sieve.c @@ -39,11 +39,76 @@ #include "policy.h" #include "database.h" #include "msgbase.h" +#include "tools.h" #ifdef HAVE_LIBSIEVE -#include "sieve2.h" -#include "sieve2_error.h" +#include +#include +#include "serv_sieve.h" + +struct RoomProcList *sieve_list = NULL; + +/* + * Add a room to the list of those rooms which potentially require sieve processing + */ +void sieve_queue_room(struct ctdlroom *which_room) { + struct RoomProcList *ptr; + + ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList)); + if (ptr == NULL) return; + + safestrncpy(ptr->name, which_room->QRname, sizeof ptr->name); + begin_critical_section(S_SIEVELIST); + ptr->next = sieve_list; + sieve_list = ptr; + end_critical_section(S_SIEVELIST); +} + + +/* + * Perform sieve processing for a single room + */ +void sieve_do_room(char *roomname) { + lprintf(CTDL_DEBUG, "Performing Sieve processing for <%s>\n", roomname); + /* FIXME ... actually do this instead of just talking about it */ +} + + +/* + * Perform sieve processing for all rooms which require it + */ +void perform_sieve_processing(void) { + struct RoomProcList *ptr = NULL; + + if (sieve_list != NULL) { + lprintf(CTDL_DEBUG, "Begin Sieve processing\n"); + while (sieve_list != NULL) { + char spoolroomname[ROOMNAMELEN]; + safestrncpy(spoolroomname, sieve_list->name, sizeof spoolroomname); + begin_critical_section(S_SIEVELIST); + + /* pop this record off the list */ + ptr = sieve_list; + sieve_list = sieve_list->next; + free(ptr); + + /* invalidate any duplicate entries to prevent double processing */ + for (ptr=sieve_list; ptr!=NULL; ptr=ptr->next) { + if (!strcasecmp(ptr->name, spoolroomname)) { + ptr->name[0] = 0; + } + } + + end_critical_section(S_SIEVELIST); + if (spoolroomname[0] != 0) { + sieve_do_room(spoolroomname); + } + } + } +} + + /** * We don't really care about dumping the entire credits to the log diff --git a/citadel/serv_sieve.h b/citadel/serv_sieve.h new file mode 100644 index 000000000..54c48c9e1 --- /dev/null +++ b/citadel/serv_sieve.h @@ -0,0 +1,8 @@ +/* + * $Id: $ + */ + +extern struct RoomProcList *sieve_list; + +void sieve_queue_room(struct ctdlroom *); +void perform_sieve_processing(void); diff --git a/citadel/server.h b/citadel/server.h index 3e59e13f5..8061e3df0 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -222,6 +222,7 @@ enum { S_ATBF, S_JOURNAL_QUEUE, S_RPLIST, + S_SIEVELIST, MAX_SEMAPHORES };