multi: handle errors returned from socket/timer callbacks

The callbacks were partially documented to support this. Now the
behavior is documented and returning error from either of these
callbacks will effectively kill all currently ongoing transfers.

Added test 530 to verify

Reported-by: Marcelo Juchem
Fixes #8083
Closes #8089
This commit is contained in:
Daniel Stenberg 2021-12-02 13:57:38 +01:00
parent b3f9c1aa09
commit 2b3dd01b77
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
14 changed files with 574 additions and 67 deletions

View file

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@ -53,6 +53,10 @@ what activity on this socket the application is supposed to
monitor. Subsequent calls to this callback might update the \fBwhat\fP bits
for a socket that is already monitored.
The socket callback should return 0 on success, and -1 on error. If this
callback returns error, \fBall\fP transfers currently in progress in this
multi handle will be aborted and fail.
\fBuserp\fP is set with \fICURLMOPT_SOCKETDATA(3)\fP.
\fBsocketp\fP is set with \fIcurl_multi_assign(3)\fP or will be NULL.

View file

@ -52,8 +52,12 @@ changed.
The \fBuserp\fP pointer is set with \fICURLMOPT_TIMERDATA(3)\fP.
The timer callback should return 0 on success, and -1 on error. This callback
can be used instead of, or in addition to, \fIcurl_multi_timeout(3)\fP.
The timer callback should return 0 on success, and -1 on error. If this
callback returns error, \fBall\fP transfers currently in progress in this
multi handle will be aborted and fail.
This callback can be used instead of, or in addition to,
\fIcurl_multi_timeout(3)\fP.
\fBWARNING:\fP even if it feels tempting, avoid calling libcurl directly from
within the callback itself when the \fBtimeout_ms\fP value is zero, since it

View file

@ -343,6 +343,7 @@ CURLMOPT_TIMERDATA 7.16.0
CURLMOPT_TIMERFUNCTION 7.16.0
CURLMSG_DONE 7.9.6
CURLMSG_NONE 7.9.6
CURLM_ABORTED_BY_CALLBACK 7.81.0
CURLM_ADDED_ALREADY 7.32.1
CURLM_BAD_EASY_HANDLE 7.9.6
CURLM_BAD_FUNCTION_ARGUMENT 7.69.0