From: Art Cancro Date: Tue, 11 Oct 2005 04:46:39 +0000 (+0000) Subject: * Replication checks and EUID indexing are now only enabled for rooms whose X-Git-Tag: v7.86~4561 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=647a017eb121e61ff023078cbea531cd389bf34d * 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. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 9bfc9fc2d..cf8f6e9fb 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 11 00:45:02 EDT 2005 Art Cancro +* 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 * IMAP STORE now calls CtdlSetSeen() with an entire list of message numbers. diff --git a/citadel/citadel.h b/citadel/citadel.h index 7f9f65a17..ecfd65fc7 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -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 */ diff --git a/citadel/euidindex.c b/citadel/euidindex.c index abab0383e..8813b9c2e 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -60,6 +60,30 @@ */ + +/* + * 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 */ } diff --git a/citadel/euidindex.h b/citadel/euidindex.h index 0072d525e..23523817c 100644 --- a/citadel/euidindex.h +++ b/citadel/euidindex.h @@ -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); diff --git a/citadel/imap_misc.c b/citadel/imap_misc.c index 9ed132c4a..7d616d1e4 100644 --- a/citadel/imap_misc.c +++ b/citadel/imap_misc.c @@ -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); } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 091335432..8e5718eaf 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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"); diff --git a/citadel/serv_upgrade.c b/citadel/serv_upgrade.c index f9fa6fab7..c54117e0f 100644 --- a/citadel/serv_upgrade.c +++ b/citadel/serv_upgrade.c @@ -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(); }