From 2f782af35b0f17615a43fff0ddc34cde5da39268 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Sat, 13 Feb 2010 17:04:17 -0800 Subject: [PATCH] validate close cb on server when client connection closes --- test/regress_http.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/regress_http.c b/test/regress_http.c index 3fd2d652..4f83b774 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -2523,6 +2523,7 @@ struct terminate_state { struct evhttp_request *req; struct bufferevent *bev; int fd; + int gotclosecb: 1; } terminate_state; 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); } +static void +terminate_chunked_close_cb(struct evhttp_connection *evcon, void *arg) +{ + struct terminate_state *state = arg; + state->gotclosecb = 1; +} + static void terminate_chunked_cb(struct evhttp_request *req, void *arg) { struct terminate_state *state = arg; 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; evhttp_send_reply_start(req, HTTP_OK, "OK"); @@ -2603,6 +2616,7 @@ http_terminate_chunked_test(void) terminate_state.fd = fd; terminate_state.bev = bev; + terminate_state.gotclosecb = 0; /* first half of the http request */ http_request = @@ -2617,6 +2631,9 @@ http_terminate_chunked_test(void) event_dispatch(); + if (terminate_state.gotclosecb == 0) + test_ok = 0; + end: if (fd >= 0) EVUTIL_CLOSESOCKET(fd);