From 80a2ff3f3aa3c62a3a60f80a7c607599b50e2559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 30 Sep 2008 14:28:12 +0000 Subject: [PATCH] Do not rely on ioctl FIONREAD (#673) git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2317 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/connections.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index c4fba762..ae0a8e51 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ NEWS * Fix base64 decoding in mod_auth (#1757, thx guido) * Fix mod_cgi segfault when bound to unix domain socket (#653) + * Do not rely on ioctl FIONREAD (#673) - 1.4.20 - 2008-09-30 diff --git a/src/connections.c b/src/connections.c index 22159b5d..404d9768 100644 --- a/src/connections.c +++ b/src/connections.c @@ -330,15 +330,13 @@ static int connection_handle_read(server *srv, connection *con) { buffer_prepare_copy(b, 4 * 1024); len = recv(con->fd, b->ptr, b->size - 1, 0); #else - if (ioctl(con->fd, FIONREAD, &toread)) { - log_error_write(srv, __FILE__, __LINE__, "sd", - "unexpected end-of-file:", - con->fd); - return -1; + if (ioctl(con->fd, FIONREAD, &toread) || toread == 0) { + b = chunkqueue_get_append_buffer(con->read_queue); + buffer_prepare_copy(b, 4 * 1024); + } else { + b = chunkqueue_get_append_buffer(con->read_queue); + buffer_prepare_copy(b, toread + 1); } - b = chunkqueue_get_append_buffer(con->read_queue); - buffer_prepare_copy(b, toread + 1); - len = read(con->fd, b->ptr, b->size - 1); #endif