From b42ce4bf08c8e70bf6b357d4e2e95885fff0d530 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 1 Jan 2011 21:17:31 -0500 Subject: [PATCH 1/5] Fix evport handling of POLLHUP and POLLERR In other backends, they make _all_ events trigger; with evport they previously triggered nothing. Found by Phua Keat Yee. --- evport.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/evport.c b/evport.c index 4301a39c..9ad2289b 100644 --- a/evport.c +++ b/evport.c @@ -336,10 +336,14 @@ evport_dispatch(struct event_base *base, struct timeval *tv) * (because we have to pass this to the callback) */ res = 0; - if (pevt->portev_events & POLLIN) - res |= EV_READ; - if (pevt->portev_events & POLLOUT) - res |= EV_WRITE; + if (pevt->portev_events & (POLLERR|POLLHUP)) { + res = EV_READ | EV_WRITE; + } else { + if (pevt->portev_events & POLLIN) + res |= EV_READ; + if (pevt->portev_events & POLLOUT) + res |= EV_WRITE; + } EVUTIL_ASSERT(epdp->ed_nevents > fd); fdi = &(epdp->ed_fds[fd]); From 926f8165a72f58f59583d21a091ffaf6bfd307b6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 13 Feb 2011 00:54:21 -0500 Subject: [PATCH 2/5] Clarify event_set_mem_functions doc --- include/event2/event.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/event2/event.h b/include/event2/event.h index 4b05b325..5a3bbf32 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -748,8 +748,9 @@ const struct timeval *event_base_init_common_timeout(struct event_base *base, Note that all memory returned from Libevent will be allocated by the replacement functions rather than by malloc() and realloc(). Thus, if you - have replaced those functions, it may not be appropriate to free() memory - that you get from Libevent. + have replaced those functions, it will not be appropriate to free() memory + that you get from Libevent. Instead, you must use the free_fn replacement + that you provided. @param malloc_fn A replacement for malloc. @param realloc_fn A replacement for realloc From f665924649b3d6306eb3c24df8f77c3671b7a082 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 15 Feb 2011 11:33:40 -0500 Subject: [PATCH 3/5] Correct evhttp_del_accept_socket documentation on whether socket is closed Thanks to Constantine Verutin for pointing this out. --- include/event2/http.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/event2/http.h b/include/event2/http.h index e05c3bff..4ffa7ac6 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -154,7 +154,10 @@ struct evconnlistener *evhttp_bound_socket_get_listener(struct evhttp_bound_sock * This may be useful when a socket has been sent via file descriptor passing * and is no longer needed by the current process. * - * This function does not close the socket. + * If you created this bound socket with evhttp_bind_socket_with_handle or + * evhttp_accept_socket_with_handle, this function closes the fd you provided. + * If you created this bound socket with evhttp_bind_listener, this function + * frees the listener you provided. * * \a bound_socket is an invalid pointer after this call returns. * From deb2f73879102b4a65df772972910f62e3a64649 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 18 Feb 2011 16:17:22 -0500 Subject: [PATCH 4/5] fix spelling mistake in whatsnew-2.0.txt --- whatsnew-2.0.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatsnew-2.0.txt b/whatsnew-2.0.txt index 3b4cfbdb..5ad6b979 100644 --- a/whatsnew-2.0.txt +++ b/whatsnew-2.0.txt @@ -75,7 +75,7 @@ What's New In Libevent 2.0 so far: evutil.h) will continue to work by including the corresponding new headers. Old code should not be broken by this change. -2.2. New thread-safe, binary-compatibile, harder-to-mess-up APIs +2.2. New thread-safe, binary-compatible, harder-to-mess-up APIs Some aspects of the historical Libevent API have encouraged non-threadsafe code, or forced code built against one version of Libevent From 63a715e125cd6ad24b672411b10946ff89d113fe Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 21 Feb 2011 23:25:13 -0500 Subject: [PATCH 5/5] Correctly detect and stop non-chunked http requests when the body is too long Based on analysis and code from Bas Verhoeven and from Constantine Verutin. --- http.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/http.c b/http.c index 53b58b41..3b947aae 100644 --- a/http.c +++ b/http.c @@ -948,7 +948,9 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req) evbuffer_remove_buffer(buf, req->input_buffer, n); } - if (req->body_size > req->evcon->max_body_size) { + if (req->body_size > req->evcon->max_body_size || + (!req->chunked && req->ntoread >= 0 && + (size_t)req->ntoread > req->evcon->max_body_size)) { /* failed body length test */ event_debug(("Request body is too long")); evhttp_connection_fail(evcon,