Fix the case when failed evhttp_make_request() leaved request in the queue.

This commit is contained in:
Tomash Brechko 2011-03-31 19:11:10 +04:00 committed by Nick Mathewson
parent 218cf19743
commit 0d6622e26a

17
http.c
View File

@ -2191,11 +2191,20 @@ evhttp_make_request(struct evhttp_connection *evcon,
req->evcon = evcon;
EVUTIL_ASSERT(!(req->flags & EVHTTP_REQ_OWN_CONNECTION));
TAILQ_INSERT_TAIL(&evcon->requests, req, next);
/* If the connection object is not connected; make it so */
if (!evhttp_connected(evcon))
return (evhttp_connection_connect(evcon));
if (!evhttp_connected(evcon)) {
int res = evhttp_connection_connect(evcon);
/*
* Enqueue the request only if we aren't going to
* return failure from evhttp_make_request().
*/
if (res == 0)
TAILQ_INSERT_TAIL(&evcon->requests, req, next);
return res;
}
TAILQ_INSERT_TAIL(&evcon->requests, req, next);
/*
* If it's connected already and we are the first in the queue,