preserve errno in evhttp_connection_fail_ for inspection by the callback

This commit is contained in:
Patrick Pelletier 2012-11-13 21:22:39 -08:00
parent 64051b903a
commit 36d0ee5c9f

7
http.c
View File

@ -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);