libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 5398d8ba644dab2a5a24efaef9de7c9bc4b7e431
parent 228df068e3df8935655e3329bc8acc8614531c58
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sat, 25 Feb 2017 21:21:52 +0300

Fixed connection states processing error introduced by 813fc203ef95f7e3b1d410e182d363a30f5fdad3

Diffstat:
Msrc/microhttpd/daemon.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -886,6 +886,7 @@ call_handlers (struct MHD_Connection *con, bool force_close) { int ret; + bool states_info_processed = false; /* Fast track flag */ bool on_fasttrack = (con->state == MHD_CONNECTION_INIT); @@ -899,6 +900,7 @@ call_handlers (struct MHD_Connection *con, { con->read_handler (con); ret = con->idle_handler (con); + states_info_processed = true; } /* No need to check value of 'ret' here as closed connection * cannot be in MHD_EVENT_LOOP_INFO_WRITE state. */ @@ -906,6 +908,7 @@ call_handlers (struct MHD_Connection *con, { con->write_handler (con); ret = con->idle_handler (con); + states_info_processed = true; } } else @@ -915,6 +918,11 @@ call_handlers (struct MHD_Connection *con, return con->idle_handler (con); } + if (!states_info_processed) + { /* Connection is not read or write ready, but external conditions + * may be changed and need to be processed. */ + ret = con->idle_handler (con); + } /* Fast track for fast connections. */ /* If full request was read by single read_handler() invocation and headers were completely prepared by single idle_handler() @@ -925,7 +933,7 @@ call_handlers (struct MHD_Connection *con, only for non-blocking sockets. */ /* No need to check 'ret' as connection is always in * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */ - if (on_fasttrack && con->sk_nonblck) + else if (on_fasttrack && con->sk_nonblck) { if (MHD_CONNECTION_HEADERS_SENDING == con->state) {