* Replication checks and EUID indexing are now only enabled for rooms whose
authorArt Cancro <ajc@citadel.org>
Tue, 11 Oct 2005 04:46:39 +0000 (04:46 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 11 Oct 2005 04:46:39 +0000 (04:46 +0000)
  default view is set to a groupware type of room.  This speeds up the saving
  and moving of messages for message and mail rooms.

citadel/ChangeLog
citadel/citadel.h
citadel/euidindex.c
citadel/euidindex.h
citadel/imap_misc.c
citadel/msgbase.c
citadel/serv_upgrade.c

index 9bfc9fc2dac18868ad05e539135555fd12bcc2df..cf8f6e9fb863c1ad8adb0948dfe94ea3896850f1 100644 (file)
@@ -1,3 +1,8 @@
+Tue Oct 11 00:45:02 EDT 2005 Art Cancro <ajc@uncensored.citadel.org>
+* Replication checks and EUID indexing are now only enabled for rooms whose
+  default view is set to a groupware type of room.  This speeds up the saving
+  and moving of messages for message and mail rooms.
+
 Mon Oct 10 00:22:49 EDT 2005 Art Cancro <ajc@uncensored.citadel.org>
 * IMAP STORE now calls CtdlSetSeen() with an entire list of message numbers.
 
index 7f9f65a1760fba11fd95971fcec17e4936d80d9b..ecfd65fc74deb48a686c2f3afdfdc6f191080e22 100644 (file)
@@ -33,7 +33,7 @@ extern "C" {
 /*
  * Text description of this software
  */
-#define CITADEL        "Citadel 6.58"
+#define CITADEL        "Citadel 6.59"
 
 /*
  * REV_LEVEL is the current version number (multiplied by 100 to avoid having
@@ -45,7 +45,7 @@ extern "C" {
  * usually more strict because you're not really supposed to dump/load and
  * upgrade at the same time.
  */
-#define REV_LEVEL      658             /* This version */
+#define REV_LEVEL      659             /* This version */
 #define REV_MIN                591             /* Oldest compatible database */
 #define EXPORT_REV_MIN 655             /* Oldest compatible export files */
 
index abab0383e49906b9561c1a613b73073174a962be..8813b9c2e79a9c2e84c209182123fa7e623cc5ef 100644 (file)
  */
 
 
+
+/*
+ * Return nonzero if the supplied room is one which should have
+ * an EUID index.
+ */
+int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf) {
+
+       switch(qrbuf->QRdefaultview) {
+               case VIEW_BBS:          return(0);
+               case VIEW_MAILBOX:      return(0);
+               case VIEW_ADDRESSBOOK:  return(1);
+               case VIEW_CALENDAR:     return(1);
+               case VIEW_TASKS:        return(1);
+               case VIEW_NOTES:        return(1);
+       }
+       
+       return(0);
+}
+
+
+
+
+
+
 /*
  * Locate a message in a given room with a given euid, and return
  * its message number.
@@ -162,9 +186,14 @@ void rebuild_euid_index_for_room(struct ctdlroom *qrbuf, void *data) {
 
        while (rplist != NULL) {
                if (getroom(&qr, rplist->name) == 0) {
-                       lprintf(CTDL_DEBUG, "Rebuilding EUID index for <%s>\n", rplist->name);
-                       usergoto(rplist->name, 0, 0, NULL, NULL);
-                       CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, rebuild_euid_index_for_msg, NULL);
+                       if (DoesThisRoomNeedEuidIndexing(&qr)) {
+                               lprintf(CTDL_DEBUG,
+                                       "Rebuilding EUID index for <%s>\n",
+                                       rplist->name);
+                               usergoto(rplist->name, 0, 0, NULL, NULL);
+                               CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL,
+                                       rebuild_euid_index_for_msg, NULL);
+                       }
                }
                ptr = rplist;
                rplist = rplist->next;
@@ -177,9 +206,9 @@ void rebuild_euid_index_for_room(struct ctdlroom *qrbuf, void *data) {
  * Globally rebuild the EUID indices in every room.
  */
 void rebuild_euid_index(void) {
-       cdb_trunc(CDB_EUIDINDEX);                       /* delete the old indices */
-       ForEachRoom(rebuild_euid_index_for_room, NULL); /* enumerate the room names */
-       rebuild_euid_index_for_room(NULL, NULL);        /* now do indexing on them */
+       cdb_trunc(CDB_EUIDINDEX);               /* delete the old indices */
+       ForEachRoom(rebuild_euid_index_for_room, NULL); /* enumerate rm names */
+       rebuild_euid_index_for_room(NULL, NULL);        /* and index them */
 }
 
 
index 0072d525eb47c96fff662cf95c4d2e9695b954cc..23523817c2a6e9bc2315a8196dc07ad7ca9662b8 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 
+int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf);
 long locate_message_by_euid(char *euid, struct ctdlroom *qrbuf);
 void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum);
 void rebuild_euid_index(void);
index 9ed132c4a360bb4b2e8a7262c9e8fe4d372bd91a..7d616d1e484c137e2ddb3de452da578bc414cedf 100644 (file)
@@ -63,6 +63,7 @@ int imap_do_copy(char *destination_folder) {
        int i;
        char roomname[ROOMNAMELEN];
        struct ctdlroom qrbuf;
+       struct timeval tv1, tv2, tv3;
 
        if (IMAP->num_msgs < 1) {
                return(0);
@@ -89,6 +90,7 @@ int imap_do_copy(char *destination_folder) {
         * performance drag.  Fix that too.
         *
         */
+       gettimeofday(&tv1, NULL);
        for (i = 0; i < IMAP->num_msgs; ++i) {
                if (IMAP->flags[i] & IMAP_SELECTED) {
                        CtdlCopyMsgToRoom(IMAP->msgids[i], roomname);
@@ -96,6 +98,7 @@ int imap_do_copy(char *destination_folder) {
        }
 
        /* Set the flags... */
+       gettimeofday(&tv2, NULL);
        i = getroom(&qrbuf, roomname);
        if (i != 0) return(i);
 
@@ -114,6 +117,15 @@ int imap_do_copy(char *destination_folder) {
                }
        }
 
+       gettimeofday(&tv3, NULL);
+       lprintf(CTDL_DEBUG, "Copying the pointers took %ld microseconds\n",
+               (tv2.tv_usec + (tv2.tv_sec * 1000))
+               - (tv1.tv_usec + (tv1.tv_sec * 1000))
+       );
+       lprintf(CTDL_DEBUG, "Setting the flags took %ld microseconds\n",
+               (tv3.tv_usec + (tv3.tv_sec * 1000))
+               - (tv2.tv_usec + (tv2.tv_sec * 1000))
+       );
        return(0);
 }
 
index 0913354329e9af4b203ae91c9102af42381af699..8e5718eaf0ea176ebd91e65331579c4160aeef80 100644 (file)
@@ -1798,7 +1798,6 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check,
 
        /* Perform replication checks if necessary */
        if ( (do_repl_check) && (msg != NULL) ) {
-
                if (getroom(&CC->room,
                   ((roomname != NULL) ? roomname : CC->room.QRname) )
                   != 0) {
@@ -2029,6 +2028,11 @@ void serialize_message(struct ser_ret *ret,              /* return values */
 void ReplicationChecks(struct CtdlMessage *msg) {
        long old_msgnum = (-1L);
 
+       if (DoesThisRoomNeedEuidIndexing(&CC->room) == 0) return;
+
+       lprintf(CTDL_DEBUG, "Performing replication checks in <%s>\n",
+               CC->room.QRname);
+
        /* No exclusive id?  Don't do anything. */
        if (msg == NULL) return;
        if (msg->cm_fields['E'] == NULL) return;
@@ -2176,9 +2180,13 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,      /* message to save */
        lprintf(CTDL_DEBUG, "Performing before-save hooks\n");
        if (PerformMessageHooks(msg, EVT_BEFORESAVE) > 0) return(-3);
 
-       /* If this message has an Exclusive ID, perform replication checks */
-       lprintf(CTDL_DEBUG, "Performing replication checks\n");
-       ReplicationChecks(msg);
+       /*
+        * If this message has an Exclusive ID, and the room is replication
+        * checking enabled, then do replication checks.
+        */
+       if (DoesThisRoomNeedEuidIndexing(&CC->room)) {
+               ReplicationChecks(msg);
+       }
 
        /* Save it to disk */
        lprintf(CTDL_DEBUG, "Saving to disk\n");
index f9fa6fab79965ac2203a9757606031bd69ab6834..c54117e0f38e54754507766dcf6a8ac1e8ea8634 100644 (file)
@@ -217,7 +217,7 @@ void check_server_upgrades(void) {
        if ((CitControl.version > 000) && (CitControl.version < 608)) {
                convert_ctdluid_to_minusone();
        }
-       if ((CitControl.version > 000) && (CitControl.version < 658)) {
+       if ((CitControl.version > 000) && (CitControl.version < 659)) {
                rebuild_euid_index();
        }