From e8a563bedfb63b908fa05d3b0e4218b987d61943 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 5 Feb 2005 04:13:35 +0000 Subject: [PATCH] * 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. --- citadel/ChangeLog | 7 ++++++- citadel/msgbase.c | 46 ++++++---------------------------------------- citadel/server.h | 1 - 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 52677ddd6..1035758a5 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 1dfcb6677..8f1849e08 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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 diff --git a/citadel/server.h b/citadel/server.h index 8b3bf2931..0c68c77d3 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -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 */ -- 2.39.2