From 6f89a8bbef4635beb73e0f21ba29498aa5da3fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 19 Mar 2016 15:01:21 +0000 Subject: [PATCH] [core] fix request_start in keep-alive requests to mark time when received first byte (fixes #2412) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Stefan Bühler git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3111 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/connections.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 707c0864..4cbcf442 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,7 @@ NEWS * restart (some) syscalls after SIGCHLD interrupted them; should fix LDAP problems (fixes #2464) * [core] log remote address on request timeouts (fixes #652) * [autobuild] use AC_CANONICAL_HOST instead of AC_CANONICAL_TARGET (fixes #1866) + * [core] fix request_start in keep-alive requests to mark time when received first byte (fixes #2412) - 1.4.39 - 2016-01-02 * [core] fix memset_s call (fixes #2698) diff --git a/src/connections.c b/src/connections.c index f01d6988..3e70e0d7 100644 --- a/src/connections.c +++ b/src/connections.c @@ -891,6 +891,8 @@ static int connection_handle_read_state(server *srv, connection *con) { chunkqueue *cq = con->read_queue; chunkqueue *dst_cq = con->request_content_queue; int is_closed = 0; /* the connection got closed, if we don't have a complete header, -> error */ + /* when in CON_STATE_READ: about to receive first byte for a request: */ + int is_request_start = chunkqueue_is_empty(cq); if (con->is_readable) { con->read_idle_ts = srv->cur_ts; @@ -913,6 +915,10 @@ static int connection_handle_read_state(server *srv, connection *con) { switch(ostate) { case CON_STATE_READ: + /* update request_start timestamp when first byte of + * next request is received on a keep-alive connection */ + if (con->request_count > 1 && is_request_start) con->request_start = srv->cur_ts; + /* if there is a \r\n\r\n in the chunkqueue * * scan the chunk-queue twice