multi: progress function abort must close connection

When the progress function returns to cancel the request, we must mark
the connection to get closed and it must do to the DONE state.

do_init() must be called as early as possible so that state variables
for new connections are reset early. We could otherwise see that the old
values were still there when a connection was to be disconnected very
early and it would make it behave wrongly.

Bug: http://curl.haxx.se/mail/lib-2011-10/0006.html
Reported by: Vladimir Grishchenko
This commit is contained in:
Daniel Stenberg 2011-10-02 19:28:39 +02:00
parent 5d45285cf3
commit 9dd85bced5
2 changed files with 12 additions and 5 deletions

View file

@ -1657,8 +1657,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
/* if there's still a connection to use, call the progress function */
else if(easy->easy_conn && Curl_pgrsUpdate(easy->easy_conn)) {
easy->result = CURLE_ABORTED_BY_CALLBACK;
multistate(easy, CURLM_STATE_COMPLETED);
/* aborted due to progress callback return code must close the
connection */
easy->easy_conn->bits.close = TRUE;
/* if not yet in DONE state, go there, otherwise COMPLETED */
multistate(easy, (easy->state < CURLM_STATE_DONE)?
CURLM_STATE_DONE: CURLM_STATE_COMPLETED);
result = CURLM_CALL_MULTI_PERFORM;
}
}
} WHILE_FALSE; /* just to break out from! */