mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-19 09:15:34 -04:00
Fix the case when failed evhttp_make_request() leaved request in the queue.
This commit is contained in:
parent
218cf19743
commit
0d6622e26a
17
http.c
17
http.c
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user