Completed a new queue (sieve_list) which will instantly
authorArt Cancro <ajc@citadel.org>
Sat, 23 Sep 2006 03:02:03 +0000 (03:02 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 23 Sep 2006 03:02:03 +0000 (03:02 +0000)
bring to the attention of the housekeeping thread, any rooms which are
inboxes and may require Sieve processing.

citadel/housekeeping.c
citadel/msgbase.c
citadel/room_ops.c
citadel/serv_extensions.h
citadel/serv_sieve.c
citadel/serv_sieve.h [new file with mode: 0644]
citadel/server.h

index 1c833f0401af04687ddbfb05dd98e2a4021867f6..365eeede3f306119ffa591badfc4cfb1272c04fa 100644 (file)
@@ -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) {
index 978b19e9d1499bc169cfa0d3725b9acc71bc994f..b6d6a0bc36168cfcd6e1cb440cc7af15d5add2ea 100644 (file)
 #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);
 
index 17dd4ff9ebf7aca9caa01efabe133e4da22204dd..240cb55dc77a9cdadf862c76953541505117bf8d 100644 (file)
@@ -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);
index f2376914973d9147daacb6a6fc6cbc3d876257bd..1868fc3355d212a46c6c113669eae385738f0c79 100644 (file)
@@ -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);
 /*
  */
 
index e9fca4f50be01397f3f2a68a9c4e00d56b8eb245..604a9f8916fa7478ce40b064348e437e4f1edfac 100644 (file)
 #include "policy.h"
 #include "database.h"
 #include "msgbase.h"
+#include "tools.h"
 
 #ifdef HAVE_LIBSIEVE
 
-#include "sieve2.h"
-#include "sieve2_error.h"
+#include <sieve2.h>
+#include <sieve2_error.h>
+#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 (file)
index 0000000..54c48c9
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * $Id: $
+ */
+
+extern struct RoomProcList *sieve_list;
+
+void sieve_queue_room(struct ctdlroom *);
+void perform_sieve_processing(void);
index 3e59e13f5fa49e79089c1b3619df4c37b45fa557..8061e3df05cbacfdb0ef79ab88b24ed82d5b5984 100644 (file)
@@ -222,6 +222,7 @@ enum {
        S_ATBF,
        S_JOURNAL_QUEUE,
        S_RPLIST,
+       S_SIEVELIST,
        MAX_SEMAPHORES
 };