<<< Date Index >>>     <<< Thread Index >>>

Re: IMAP problem sending mail



On Tuesday, 26 July 2005 at 12:39, Brendan Cully wrote:
> On Tuesday, 26 July 2005 at 13:44, Sayantan Sur wrote:
> > Hi,
> > 
> > This is a peculiar problem I have been experiencing using IMAP support
> > with mutt. To reproduce the problem, do this:
> > 
> > 1) Open inbox
> > 2) Start composing mail
> > 3) Send an email to your account (from which you are composing) using
> > any other email (e.g. Gmail)
> > 4) Complete composing mail
> > 5) Press 'y' to send out the mail
> > 6) You will see an error like "Connection to remote server closed",
> > followed by "Create Mail/Sent?" [apparently mutt attempts to create a
> > local sent folder, whereas my sent folder is on the imap host].
> > Additionally, on trying to postpone the message (i.e. attempting to
> > save what you have typed) sometimes leads to segfault.
> 
> According to the muttdebug log, this problem is set off because your
> IMAP server is crashing. So it's not easy for those of us with better
> servers to reproduce. But try the following untested patch and let us
> know what the new behaviour is.

I've tormented you all enough with the anticipation. Here's the patch.
? cscope.files
? cscope.out
? fatal.diff
Index: imap/command.c
===================================================================
RCS file: /home/roessler/cvs/mutt/imap/command.c,v
retrieving revision 3.12
diff -u -p -r3.12 command.c
--- imap/command.c      3 Feb 2005 17:01:44 -0000       3.12
+++ imap/command.c      26 Jul 2005 19:32:23 -0000
@@ -287,8 +287,7 @@ static void cmd_handle_fatal (IMAP_DATA*
   idata->status = IMAP_FATAL;
 
   if ((idata->state == IMAP_SELECTED) &&
-      (idata->reopen & IMAP_REOPEN_ALLOW) &&
-      !idata->ctx->closing)
+      (idata->reopen & IMAP_REOPEN_ALLOW))
   {
     mx_fastclose_mailbox (idata->ctx);
     mutt_error (_("Mailbox closed"));
@@ -299,6 +298,7 @@ static void cmd_handle_fatal (IMAP_DATA*
   if (idata->state != IMAP_SELECTED)
   {
     idata->state = IMAP_DISCONNECTED;
+    mutt_socket_close (idata->conn);
     idata->status = 0;
   }
 }
@@ -376,11 +376,8 @@ static int cmd_handle_untagged (IMAP_DAT
     s += 3;
     SKIPWS (s);
     mutt_error ("%s", s);
-    idata->status = IMAP_BYE;
-    if (idata->state == IMAP_SELECTED)
-      mx_fastclose_mailbox (idata->ctx);
-    mutt_socket_close (idata->conn);
-    idata->state = IMAP_DISCONNECTED;
+    mutt_sleep (2);
+    cmd_handle_fatal (idata);
 
     return -1;
   }
Index: imap/imap.c
===================================================================
RCS file: /home/roessler/cvs/mutt/imap/imap.c,v
retrieving revision 3.27
diff -u -p -r3.27 imap.c
--- imap/imap.c 26 Jul 2005 16:44:20 -0000      3.27
+++ imap/imap.c 26 Jul 2005 19:32:24 -0000
@@ -1139,12 +1139,11 @@ void imap_close_mailbox (CONTEXT* ctx)
 
   if (ctx == idata->ctx)
   {
-    if (idata->state == IMAP_SELECTED)
+    if (idata->status != IMAP_FATAL && idata->state == IMAP_SELECTED)
     {
       /* mx_close_mailbox won't sync if there are no deleted messages
        * and the mailbox is unchanged, so we may have to close here */
-      if (idata->status != IMAP_FATAL && !ctx->deleted &&
-          imap_exec (idata, "CLOSE", 0))
+      if (!ctx->deleted && imap_exec (idata, "CLOSE", 0))
         mutt_error (_("CLOSE failed"));
       idata->state = IMAP_AUTHENTICATED;
     }