mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 21:10:06 -04:00
validate close cb on server when client connection closes
This commit is contained in:
parent
e8a9782c1d
commit
2f782af35b
@ -2523,6 +2523,7 @@ struct terminate_state {
|
|||||||
struct evhttp_request *req;
|
struct evhttp_request *req;
|
||||||
struct bufferevent *bev;
|
struct bufferevent *bev;
|
||||||
int fd;
|
int fd;
|
||||||
|
int gotclosecb: 1;
|
||||||
} terminate_state;
|
} terminate_state;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2548,12 +2549,24 @@ terminate_chunked_trickle_cb(evutil_socket_t fd, short events, void *arg)
|
|||||||
event_once(-1, EV_TIMEOUT, terminate_chunked_trickle_cb, arg, &tv);
|
event_once(-1, EV_TIMEOUT, terminate_chunked_trickle_cb, arg, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
terminate_chunked_close_cb(struct evhttp_connection *evcon, void *arg)
|
||||||
|
{
|
||||||
|
struct terminate_state *state = arg;
|
||||||
|
state->gotclosecb = 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
terminate_chunked_cb(struct evhttp_request *req, void *arg)
|
terminate_chunked_cb(struct evhttp_request *req, void *arg)
|
||||||
{
|
{
|
||||||
struct terminate_state *state = arg;
|
struct terminate_state *state = arg;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
|
/* we want to know if this connection closes on us */
|
||||||
|
evhttp_connection_set_closecb(
|
||||||
|
evhttp_request_get_connection(req),
|
||||||
|
terminate_chunked_close_cb, arg);
|
||||||
|
|
||||||
state->req = req;
|
state->req = req;
|
||||||
|
|
||||||
evhttp_send_reply_start(req, HTTP_OK, "OK");
|
evhttp_send_reply_start(req, HTTP_OK, "OK");
|
||||||
@ -2603,6 +2616,7 @@ http_terminate_chunked_test(void)
|
|||||||
|
|
||||||
terminate_state.fd = fd;
|
terminate_state.fd = fd;
|
||||||
terminate_state.bev = bev;
|
terminate_state.bev = bev;
|
||||||
|
terminate_state.gotclosecb = 0;
|
||||||
|
|
||||||
/* first half of the http request */
|
/* first half of the http request */
|
||||||
http_request =
|
http_request =
|
||||||
@ -2617,6 +2631,9 @@ http_terminate_chunked_test(void)
|
|||||||
|
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
|
if (terminate_state.gotclosecb == 0)
|
||||||
|
test_ok = 0;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
EVUTIL_CLOSESOCKET(fd);
|
EVUTIL_CLOSESOCKET(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user