* msgbase.c: replication checks for Exclusive-ID no longer cause a save
authorArt Cancro <ajc@citadel.org>
Sat, 5 Feb 2005 04:13:35 +0000 (04:13 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 5 Feb 2005 04:13:35 +0000 (04:13 +0000)
  operation to fail when the existing message is newer.  This was causing
  groupware clients to go haywire because of datestamps being set to
  event start times, etc.

citadel/ChangeLog
citadel/msgbase.c
citadel/server.h

index 52677ddd6c790589f9a189b95e01fb8b587d38b4..1035758a5827936264545eecfe4694917b4413ee 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 630.13  2005/02/05 04:13:34  ajc
+ * msgbase.c: replication checks for Exclusive-ID no longer cause a save
+   operation to fail when the existing message is newer.  This was causing
+   groupware clients to go haywire because of datestamps being set to
+   event start times, etc.
+
  Revision 630.12  2005/02/03 04:36:56  ajc
  * serv_calendar.c: beforesave hook now looks for the UID inside nested
    VTODO components, in addition to VCALENDAR components.
@@ -6346,4 +6352,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 1dfcb6677a2998195b2622aa8c8ec2b096352f71..8f1849e08716c795b7065923c1cf2f4dc53d1345 100644 (file)
@@ -53,7 +53,6 @@
 
 #define desired_section ((char *)CtdlGetUserData(SYM_DESIRED_SECTION))
 #define ma ((struct ma_info *)CtdlGetUserData(SYM_MA_INFO))
-#define msg_repl ((struct repl *)CtdlGetUserData(SYM_REPL))
 
 extern struct config config;
 long config_msgnum;
@@ -1850,64 +1849,31 @@ void serialize_message(struct ser_ret *ret,             /* return values */
  * Back end for the ReplicationChecks() function
  */
 void check_repl(long msgnum, void *userdata) {
-       struct CtdlMessage *msg;
-       time_t timestamp = (-1L);
-
-       lprintf(CTDL_DEBUG, "check_repl() found message %ld\n", msgnum);
-       msg = CtdlFetchMessage(msgnum, 1);
-       if (msg == NULL) return;
-       if (msg->cm_fields['T'] != NULL) {
-               timestamp = atol(msg->cm_fields['T']);
-       }
-       CtdlFreeMessage(msg);
-
-       if (timestamp > msg_repl->highest) {
-               msg_repl->highest = timestamp;  /* newer! */
-               lprintf(CTDL_DEBUG, "newer!\n");
-               return;
-       }
-       lprintf(CTDL_DEBUG, "older!\n");
-
-       /* Existing isn't newer?  Then delete the old one(s). */
+       lprintf(CTDL_DEBUG, "check_repl() replacing message %ld\n", msgnum);
        CtdlDeleteMessages(CC->room.QRname, msgnum, "");
 }
 
 
 /*
  * Check to see if any messages already exist which carry the same Exclusive ID
- * as this one.  
+ * as this one.  If any are found, delete them.
  *
- * If any are found:
- * -> With older timestamps: delete them and return 0.  Message will be saved.
- * -> With newer timestamps: return 1.  Message save will be aborted.
  */
 int ReplicationChecks(struct CtdlMessage *msg) {
        struct CtdlMessage *template;
        int abort_this = 0;
 
-       lprintf(CTDL_DEBUG, "ReplicationChecks() started\n");
        /* No exclusive id?  Don't do anything. */
        if (msg->cm_fields['E'] == NULL) return 0;
        if (strlen(msg->cm_fields['E']) == 0) return 0;
        lprintf(CTDL_DEBUG, "Exclusive ID: <%s>\n", msg->cm_fields['E']);
 
-       CtdlAllocUserData(SYM_REPL, sizeof(struct repl));
-       strcpy(msg_repl->exclusive_id, msg->cm_fields['E']);
-       msg_repl->highest = atol(msg->cm_fields['T']);
-
        template = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage));
        memset(template, 0, sizeof(struct CtdlMessage));
        template->cm_fields['E'] = strdup(msg->cm_fields['E']);
 
        CtdlForEachMessage(MSGS_ALL, 0L, NULL, template, check_repl, NULL);
 
-       /* If a newer message exists with the same Exclusive ID, abort
-        * this save.
-        */
-       if (msg_repl->highest > atol(msg->cm_fields['T']) ) {
-               abort_this = 1;
-               }
-
        CtdlFreeMessage(template);
        lprintf(CTDL_DEBUG, "ReplicationChecks() returning %d\n", abort_this);
        return(abort_this);
@@ -1981,7 +1947,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        lprintf(CTDL_DEBUG, "Learning what's inside\n");
        if (msg->cm_fields['M'] == NULL) {
                lprintf(CTDL_ERR, "ERROR: attempt to save message with NULL body\n");
-               return(-1);
+               return(-2);
        }
 
        switch (msg->cm_format_type) {
@@ -2050,16 +2016,16 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
 
        /* Perform "before save" hooks (aborting if any return nonzero) */
        lprintf(CTDL_DEBUG, "Performing before-save hooks\n");
-       if (PerformMessageHooks(msg, EVT_BEFORESAVE) > 0) return(-1);
+       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");
-       if (ReplicationChecks(msg) > 0) return(-1);
+       if (ReplicationChecks(msg) > 0) return(-4);
 
        /* Save it to disk */
        lprintf(CTDL_DEBUG, "Saving to disk\n");
        newmsgid = send_message(msg);
-       if (newmsgid <= 0L) return(-1);
+       if (newmsgid <= 0L) return(-5);
 
        /* Write a supplemental message info record.  This doesn't have to
         * be a critical section because nobody else knows about this message
index 8b3bf29315bd494efc85aecf7a066e779c68af22..0c68c77d3a18bf856433903762dd589baad54d52 100644 (file)
@@ -46,7 +46,6 @@ struct CtdlSessData {
 enum {
        SYM_DESIRED_SECTION,            /* Used by the MIME parser */
        SYM_MA_INFO,                    /* Handles multipart/alternative */
-       SYM_REPL,                       /* Used for replication checking */
        SYM_CIT_ICAL,                   /* Used by the calendar service */
        SYM_IMAP,                       /* Used by the IMAP service */
        SYM_POP3,                       /* Used by the POP3 service */