aboutsummaryrefslogtreecommitdiffstats
path: root/main/lighttpd/0013-connections-fix-bug-in-connection-state-handling.patch
blob: 15677598999a0708a61105479ee6736eacb91e55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From d00e1e79b94e0f4da35292d2293595dac02993c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BChler?= <stbuehler@web.de>
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 <stbuehler@web.de>

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