summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjan <jan@152afb58-edef-0310-8abb-c4023f1b3aa9>2006-08-03 09:28:05 +0000
committerjan <jan@152afb58-edef-0310-8abb-c4023f1b3aa9>2006-08-03 09:28:05 +0000
commit8e626a8076e6ba3b3602c0308f6ad260d0e9cfe8 (patch)
treedf9dfff7c3ecb177029bf47a2b82695b175f968e
parent6e7ff25ffc300b23b6f75fa22f5998109286477f (diff)
downloadlighttpd-8e626a8076e6ba3b3602c0308f6ad260d0e9cfe8.tar.gz
only load 128kb in a row to don't run into a endless read scenario
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@1230 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--src/network_write.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/network_write.c b/src/network_write.c
index 57c263a7..59b66d97 100644
--- a/src/network_write.c
+++ b/src/network_write.c
@@ -37,16 +37,19 @@
NETWORK_BACKEND_READ(read) {
int toread;
buffer *b;
- off_t r;
+ off_t r, start_bytes_in;
+ off_t max_read = 256 * 1024;
/**
* a EAGAIN is a successful read if we already read something to the chunkqueue
*/
int read_something = 0;
- /* use a chunk-size of 8k */
+ start_bytes_in = cq->bytes_in;
+
+ /* use a chunk-size of 16k */
do {
- toread = 8192;
+ toread = 16384;
b = chunkqueue_get_append_buffer(cq);
@@ -76,6 +79,9 @@ NETWORK_BACKEND_READ(read) {
b->used = r;
b->ptr[b->used++] = '\0';
+ cq->bytes_in += r;
+
+ if (cq->bytes_in - start_bytes_in > max_read) break;
} while (r == toread);
return NETWORK_STATUS_SUCCESS;