From d00e1e79b94e0f4da35292d2293595dac02993c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 7 Feb 2015 13:32:54 +0000 Subject: [PATCH 13/29] [connections] fix bug in connection state handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if a request was finished (con->file_finished = 1) and the state machine was triggered, but the write queue was empty, it didn't actually finish the request. From: Stefan Bühler git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2973 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/connections.c | 22 +++++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index bf8984f..9c579de 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ NEWS * [ssl] disable SSL3.0 by default * fixed typo in example config found by openSUSE user (boo# 907709) * [network] fix compile break in calculation of sockaddr_un size if SUN_LEN is not defined (fixes #2609) + * [connections] fix bug in connection state handling - 1.4.35 - 2014-03-12 * [network/ssl] fix build error if TLSEXT is disabled diff --git a/src/connections.c b/src/connections.c index bbaa632..fe683a2 100644 --- a/src/connections.c +++ b/src/connections.c @@ -1632,20 +1632,16 @@ int connection_state_machine(server *srv, connection *con) { /* only try to write if we have something in the queue */ if (!chunkqueue_is_empty(con->write_queue)) { -#if 0 - log_error_write(srv, __FILE__, __LINE__, "dsd", - con->fd, - "packets to write:", - con->write_queue->used); -#endif - } - if (!chunkqueue_is_empty(con->write_queue) && con->is_writable) { - if (-1 == connection_handle_write(srv, con)) { - log_error_write(srv, __FILE__, __LINE__, "ds", - con->fd, - "handle write failed."); - connection_set_state(srv, con, CON_STATE_ERROR); + if (con->is_writable) { + if (-1 == connection_handle_write(srv, con)) { + log_error_write(srv, __FILE__, __LINE__, "ds", + con->fd, + "handle write failed."); + connection_set_state(srv, con, CON_STATE_ERROR); + } } + } else if (con->file_finished) { + connection_set_state(srv, con, CON_STATE_RESPONSE_END); } break; -- 2.4.5