Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-10-28 18:45:41 +0300
committerIgor Sysoev <igor@sysoev.ru>2003-10-28 18:45:41 +0300
commitab0c4f5038cec58e23a023d8a1e01be038504e3e (patch)
tree2857bfcbd81676e018df566a94004ea3d942764e /src/os/unix/ngx_readv_chain.c
parent2b0c76cfbdfd660242f47ce66a4d54d30f9b23e8 (diff)
nginx-0.0.1-2003-10-28-18:45:41 import
Diffstat (limited to 'src/os/unix/ngx_readv_chain.c')
-rw-r--r--src/os/unix/ngx_readv_chain.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index c83b076ce..f19569879 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -6,23 +6,30 @@
ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
{
+ char *prev;
ssize_t n;
struct iovec *iov;
ngx_err_t err;
ngx_array_t io;
-#if (NGX_SUPPRESS_WARN)
+ prev = NULL;
iov = NULL;
-#endif
ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
- /* TODO: coalesce the neighbouring chain entries */
+ /* coalesce the neighbouring hunks */
while (chain) {
- ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
- iov->iov_base = chain->hunk->last;
- iov->iov_len = chain->hunk->end - chain->hunk->last;
+ if (prev == chain->hunk->last) {
+ iov->iov_len += chain->hunk->end - chain->hunk->last;
+
+ } else {
+ ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+ iov->iov_base = chain->hunk->last;
+ iov->iov_len = chain->hunk->end - chain->hunk->last;
+ }
+
+ prev = chain->hunk->end;
chain = chain->next;
}
@@ -30,8 +37,12 @@ ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
- if (n == -1) {
+ if (n == 0) {
+ c->read->eof = 1;
+
+ } else if (n == -1) {
c->read->ready = 0;
+ c->read->error = 1;
err = ngx_errno;
if (err == NGX_EAGAIN) {