mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
preserve errno in evhttp_connection_fail_ for inspection by the callback
This commit is contained in:
parent
64051b903a
commit
36d0ee5c9f
7
http.c
7
http.c
@ -681,6 +681,7 @@ void
|
||||
evhttp_connection_fail_(struct evhttp_connection *evcon,
|
||||
enum evhttp_connection_error error)
|
||||
{
|
||||
const int errsave = errno;
|
||||
struct evhttp_request* req = TAILQ_FIRST(&evcon->requests);
|
||||
void (*cb)(struct evhttp_request *, void *);
|
||||
void *cb_arg;
|
||||
@ -726,6 +727,12 @@ evhttp_connection_fail_(struct evhttp_connection *evcon,
|
||||
if (TAILQ_FIRST(&evcon->requests) != NULL)
|
||||
evhttp_connection_connect_(evcon);
|
||||
|
||||
/* The call to evhttp_connection_reset_ overwrote errno.
|
||||
* Let's restore the original errno, so that the user's
|
||||
* callback can have a better idea of what the error was.
|
||||
*/
|
||||
errno = errsave;
|
||||
|
||||
/* inform the user */
|
||||
if (cb != NULL)
|
||||
(*cb)(NULL, cb_arg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user