aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_recv_chain.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-04-10 15:08:54 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-04-10 15:08:54 +0000
commitcde2478a8540b19d4c9f5077fae23803889ed393 (patch)
tree81ba616f9fd6f570dee53368d0ec583cab40e9dd /src/os/unix/ngx_recv_chain.c
parent183f9a6dce035cd61be251ffcd6540a3fe28b199 (diff)
downloadnginx-cde2478a8540b19d4c9f5077fae23803889ed393.tar.gz
nginx-cde2478a8540b19d4c9f5077fae23803889ed393.zip
nginx-0.0.1-2003-04-10-19:08:54 import
Diffstat (limited to 'src/os/unix/ngx_recv_chain.c')
-rw-r--r--src/os/unix/ngx_recv_chain.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/os/unix/ngx_recv_chain.c b/src/os/unix/ngx_recv_chain.c
new file mode 100644
index 000000000..221f306cd
--- /dev/null
+++ b/src/os/unix/ngx_recv_chain.c
@@ -0,0 +1,42 @@
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_errno.h>
+#include <ngx_log.h>
+#include <ngx_connection.h>
+
+
+ssize_t ngx_recv_chain(ngx_connection_t *c, ngx_chain_t *ce)
+{
+ int n;
+ struct iovec *iov;
+ ngx_err_t err;
+ ngx_array_t io;
+
+ ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
+
+ while (ce) {
+ ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+ iov->iov_base = ce->hunk->pos;
+ iov->iov_len = ce->hunk->last - ce->hunk->pos;
+ ce = ce->next;
+ }
+
+ n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
+
+ ngx_destroy_array(&io);
+
+ if (n == -1) {
+ c->read->ready = 0;
+
+ 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;
+}