progress callback: skip last callback update on errors
authorRay Satiro <raysatiro@yahoo.com>
Mon, 9 Jun 2014 21:57:14 +0000 (23:57 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 2 Jul 2014 21:53:25 +0000 (23:53 +0200)
When an error has been detected, skip the final forced call to the
progress callback by making sure to pass the current return code
variable in the Curl_done() call in the CURLM_STATE_DONE state.

This avoids the "extra" callback that could occur even if you returned
error from the progress callback.

Bug: http://curl.haxx.se/mail/lib-2014-06/0062.html
Reported by: Jonathan Cardoso Machado

lib/multi.c
lib/url.c

index 1fb341c..ca975a0 100644 (file)
@@ -1610,7 +1610,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
         Curl_multi_process_pending_handles(multi);
 
         /* post-transfer command */
-        res = Curl_done(&data->easy_conn, CURLE_OK, FALSE);
+        res = Curl_done(&data->easy_conn, data->result, FALSE);
 
         /* allow a previously set error code take precedence */
         if(!data->result)
index 770b0cc..5209c8d 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -5796,9 +5796,9 @@ CURLcode Curl_done(struct connectdata **connp,
   if(conn->handler->done)
     result = conn->handler->done(conn, status, premature);
   else
-    result = CURLE_OK;
+    result = status;
 
-  if(Curl_pgrsDone(conn) && !result)
+  if(!result && Curl_pgrsDone(conn))
     result = CURLE_ABORTED_BY_CALLBACK;
 
   /* if the transfer was completed in a paused state there can be buffered