Blob Blame History Raw
From 0b235958053144d0dd1a4c9e36458b97d636cab6 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Fri, 8 Feb 2013 13:48:56 +0100
Subject: [PATCH 1/2] DONE: consider callback-aborted transfers premature

This bug report properly identified that when doing SMTP and aborting
the transfer with a callback, it must be considered aborted prematurely
by the code to avoid QUIT etc to be attempted as that would cause a
hang.

The new test case 1507 verifies this behavior.

Reported by: Patricia Muscalu
Bug: http://curl.haxx.se/bug/view.cgi?id=1184

[upstream commit 72688317adcedb9508fd2189e6c6d3945e06a004]

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 lib/url.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/url.c b/lib/url.c
index da53086..17a4714 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -5376,6 +5376,13 @@ CURLcode Curl_done(struct connectdata **connp,
     conn->dns_entry = NULL;
   }
 
+  if(status == CURLE_ABORTED_BY_CALLBACK)
+    /* When we're aborted due to a callback return code it basically have to
+       be counted as premature as there is trouble ahead if we don't. We have
+       many callbacks and protocols work differently, we could potentially do
+       this more fine-grained in the future. */
+    premature = TRUE;
+
   /* this calls the protocol-specific function pointer previously set */
   if(conn->handler->done)
     result = conn->handler->done(conn, status, premature);
-- 
1.7.1


From f365fe7a4a68bc6fbd467192667b90d208db82f8 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Mon, 9 Sep 2013 13:10:53 +0200
Subject: [PATCH 2/2] url: handle abortion by read/write callbacks, too

Otherwise, the FTP protocol would unnecessarily hang 60 seconds if
aborted in the CURLOPT_HEADERFUNCTION callback.

Reported by: Tomas Mlcoch
Bug: https://bugzilla.redhat.com/1005686

[upstream commit c639d725a37c91fb49bb3a689cb2596fad3a0645]
---
 lib/url.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/lib/url.c b/lib/url.c
index 17a4714..adbdace 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -5376,12 +5376,18 @@ CURLcode Curl_done(struct connectdata **connp,
     conn->dns_entry = NULL;
   }
 
-  if(status == CURLE_ABORTED_BY_CALLBACK)
+  switch(status) {
+  case CURLE_ABORTED_BY_CALLBACK:
+  case CURLE_READ_ERROR:
+  case CURLE_WRITE_ERROR:
     /* When we're aborted due to a callback return code it basically have to
        be counted as premature as there is trouble ahead if we don't. We have
        many callbacks and protocols work differently, we could potentially do
        this more fine-grained in the future. */
     premature = TRUE;
+  default:
+    break;
+  }
 
   /* this calls the protocol-specific function pointer previously set */
   if(conn->handler->done)
-- 
1.7.1