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

Re: fixing mutt



On Friday, July 10 at 05:24 AM, quoth b a:
When pressing <enter> to view an email with a big attachement mutt becomes unresponsive until the message is fetched.

I've had the same complaint.

I don't like this and I will fix it in the next few days by binding the escape key to break the loop on lines 463 - 516 inside message.c in imap_fetch_message. That loop is getting the message,and if it's 22MB for example you'll have to wait for some time , what if you decide you DON'T want to download it any more and you want to interrupt the fetching process?

Indeed! Although it would be far more useful if mutt could download *partial* messages... but it's not really set up for offloading MIME decomposition to the IMAP server.

I forgot to mention that what I want to get done is listed under the file imap/TODO

9 * Interruptible socket calls, preferably without having to abort the 10 connection. For example large downloads could be chunked.

What I do is simply allow interrupts during socket reads. It's clunky, because it aborts the connection, but it gets the job done (see attachment).

~Kyle
--
What progress we are making. In the Middle Ages they would have burned me. Now they are content with burning my books.
                                                      -- Sigmund Freud
diff -r d5e03a46518c mutt_socket.c
--- a/mutt_socket.c     Tue Jul 07 15:03:53 2009 +0200
+++ b/mutt_socket.c     Thu Jul 09 21:37:12 2009 -0500
@@ -75,10 +75,12 @@
 {
   int rc = -1;
 
+  mutt_allow_interrupt (1);
   if (conn->fd < 0)
     dprint (1, (debugfile, "mutt_socket_close: Attempt to close closed 
connection.\n"));
   else
     rc = conn->conn_close (conn);
+  mutt_allow_interrupt (0);
 
   conn->fd = -1;
   conn->ssf = 0;
@@ -96,7 +98,9 @@
     return -1;
   }
 
+  mutt_allow_interrupt (1);
   rc = conn->conn_read (conn, buf, len);
+  mutt_allow_interrupt (0);
   /* EOF */
   if (rc == 0)
   {
@@ -127,8 +131,10 @@
   
   while (sent < len)
   {
+    mutt_allow_interrupt (1);
     if ((rc = conn->conn_write (conn, buf + sent, len - sent)) < 0)
     {
+      mutt_allow_interrupt (0);
       dprint (1, (debugfile,
                   "mutt_socket_write: error writing (%s), closing socket\n",
                   strerror(errno)));
@@ -136,6 +142,7 @@
 
       return -1;
     }
+    mutt_allow_interrupt (0);
 
     if (rc < len - sent)
       dprint (3, (debugfile,
@@ -169,7 +176,11 @@
   if (conn->bufpos >= conn->available)
   {
     if (conn->fd >= 0)
+    {
+      mutt_allow_interrupt (1);
       conn->available = conn->conn_read (conn, conn->inbuf, sizeof 
(conn->inbuf));
+      mutt_allow_interrupt (0);
+    }
     else
     {
       dprint (1, (debugfile, "mutt_socket_readchar: attempt to read from 
closed connection.\n"));

Attachment: pgpW53fhbXJ09.pgp
Description: PGP signature