diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-05-21 13:28:21 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-05-21 13:28:21 +0000 |
commit | fa73aac7747c9d0a8575eb2beffcdab50171e006 (patch) | |
tree | d1e354f2e321b8f1c4e5518984759bab1ae05ddd /src/os/unix/ngx_readv_chain.c | |
parent | 1c13c662f0ae8066d1d4849b4158d7459a4c7822 (diff) | |
download | nginx-fa73aac7747c9d0a8575eb2beffcdab50171e006.tar.gz nginx-fa73aac7747c9d0a8575eb2beffcdab50171e006.zip |
nginx-0.0.1-2003-05-21-17:28:21 import
Diffstat (limited to 'src/os/unix/ngx_readv_chain.c')
-rw-r--r-- | src/os/unix/ngx_readv_chain.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c new file mode 100644 index 000000000..8432f0c8d --- /dev/null +++ b/src/os/unix/ngx_readv_chain.c @@ -0,0 +1,46 @@ + +#include <ngx_config.h> +#include <ngx_core.h> + + +ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry) +{ + ssize_t n; + struct iovec *iov; + ngx_err_t err; + ngx_array_t io; + +#if (NGX_SUPPRESS_WARN) + iov = NULL; +#endif + + ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR); + + while (entry) { + ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR); + iov->iov_base = entry->hunk->pos; + iov->iov_len = entry->hunk->end - entry->hunk->last; + entry = entry->next; + } + +ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len); + + n = readv(c->fd, (struct iovec *) io.elts, io.nelts); + + ngx_destroy_array(&io); + + if (n == -1) { + c->read->ready = 0; + + err = ngx_errno; + if (err == NGX_EAGAIN) { + ngx_log_error(NGX_LOG_INFO, c->log, err, "readv() returned EAGAIN"); + return NGX_AGAIN; + } + + ngx_log_error(NGX_LOG_ERR, c->log, err, "readv() failed"); + return NGX_ERROR; + } + + return n; +} |