hi,

On Tue, Sep 17, 2013 at 10:10:41AM +0100, Alex Bennée wrote:
> I see this has already been reported on the mailing list:
> 
yes, and a few days before that as well.

> But there was no response I could see in the archive.
> 
i was on vacation. ^^

> >>> 9 UID FETCH 1:70 (UID FLAGS)
> * 1 FETCH (UID 1 FLAGS (\Seen \Draft))
> 9 OK FETCH completed.
> >>> 10 UID FETCH 1 (BODY.PEEK[])
> 10 OK FETCH completed.
> 
the message apparently disappeared between the two commands.
what i don't understand is why "everyone" is suddenly having this
problem (two reports are with exchange, one with gmail).
i initially suspected commit c206dd85, but the first report is even
before that.

the attached patch should fix the crash. even though the fix is not just
a workaround, it would be interesting to figure out what triggers the
problem in your particular cases.
for starters, the -V logs of two subsequent sync runs (of which the
first would have crashed before) should be looked at. if the second log
indicates syncing activity (even though no new messages arrived),
something weird is going on. if not, then this is just some incredible
coincidence. ^^

>From 3dff765ff071ee30b7f9d066be4084b0018c8329 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <[email protected]>
Date: Wed, 25 Sep 2013 17:13:00 +0200
Subject: [PATCH] deal with messages disappearing between being listed and
 fetched

---
 src/drv_imap.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c
index abfc760..71ba303 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -1761,6 +1761,8 @@ imap_submit_load( imap_store_t *ctx, const char *buf, int tuids, struct imap_cmd
 
 /******************* imap_fetch_msg *******************/
 
+static void imap_fetch_msg_p2( imap_store_t *ctx, struct imap_cmd *gcmd, int response );
+
 static void
 imap_fetch_msg( store_t *ctx, message_t *msg, msg_data_t *data,
                 void (*cb)( int sts, void *aux ), void *aux )
@@ -1770,12 +1772,25 @@ imap_fetch_msg( store_t *ctx, message_t *msg, msg_data_t *data,
 	INIT_IMAP_CMD_X(imap_cmd_fetch_msg, cmd, cb, aux)
 	cmd->gen.gen.param.uid = msg->uid;
 	cmd->msg_data = data;
-	imap_exec( (imap_store_t *)ctx, &cmd->gen.gen, imap_done_simple_msg,
+	data->data = 0;
+	imap_exec( (imap_store_t *)ctx, &cmd->gen.gen, imap_fetch_msg_p2,
 	           "UID FETCH %d (%s%sBODY.PEEK[])", msg->uid,
 	           !(msg->status & M_FLAGS) ? "FLAGS " : "",
 	           (data->date== -1) ? "INTERNALDATE " : "" );
 }
 
+static void
+imap_fetch_msg_p2( imap_store_t *ctx, struct imap_cmd *gcmd, int response )
+{
+	struct imap_cmd_fetch_msg *cmd = (struct imap_cmd_fetch_msg *)gcmd;
+
+	if (response == RESP_OK && !cmd->msg_data->data) {
+		/* The FETCH succeeded, but there is no message with this UID. */
+		response = RESP_NO;
+	}
+	imap_done_simple_msg( ctx, gcmd, response );
+}
+
 /******************* imap_set_flags *******************/
 
 static void imap_set_flags_p2( imap_store_t *, struct imap_cmd *, int );
-- 
1.8.0.1.18.g93341d8

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to