progresscallback: make CURLE_ABORTED_BY_CALLBACK get returned better

When the progress callback returned 1 at a very early state, the code
would not make CURLE_ABORTED_BY_CALLBACK get returned but the process
would still be interrupted. In the HTTP case, this would then cause a
CURLE_GOT_NOTHING to erroneously get returned instead.

Reported-by: Petr Novak
Bug: http://curl.haxx.se/bug/view.cgi?id=1318
This commit is contained in:
Daniel Stenberg 2014-01-02 23:24:26 +01:00
parent d28b70d152
commit bf24b64e83
1 changed files with 10 additions and 2 deletions

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -1585,13 +1585,20 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
result = CURLM_CALL_MULTI_PERFORM; result = CURLM_CALL_MULTI_PERFORM;
if(data->easy_conn) { if(data->easy_conn) {
CURLcode res;
/* Remove ourselves from the receive pipeline, if we are there. */ /* Remove ourselves from the receive pipeline, if we are there. */
Curl_removeHandleFromPipeline(data, data->easy_conn->recv_pipe); Curl_removeHandleFromPipeline(data, data->easy_conn->recv_pipe);
/* Check if we can move pending requests to send pipe */ /* Check if we can move pending requests to send pipe */
Curl_multi_process_pending_handles(multi); Curl_multi_process_pending_handles(multi);
/* post-transfer command */ /* post-transfer command */
data->result = Curl_done(&data->easy_conn, CURLE_OK, FALSE); res = Curl_done(&data->easy_conn, CURLE_OK, FALSE);
/* allow a previously set error code take precedence */
if(!data->result)
data->result = res;
/* /*
* If there are other handles on the pipeline, Curl_done won't set * If there are other handles on the pipeline, Curl_done won't set
* easy_conn to NULL. In such a case, curl_multi_remove_handle() can * easy_conn to NULL. In such a case, curl_multi_remove_handle() can
@ -1680,6 +1687,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) { else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) {
/* aborted due to progress callback return code must close the /* aborted due to progress callback return code must close the
connection */ connection */
data->result = CURLE_ABORTED_BY_CALLBACK;
data->easy_conn->bits.close = TRUE; data->easy_conn->bits.close = TRUE;
/* if not yet in DONE state, go there, otherwise COMPLETED */ /* if not yet in DONE state, go there, otherwise COMPLETED */