aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_readv_chain.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-03-19 12:38:37 +0000
committerIgor Sysoev <igor@sysoev.ru>2005-03-19 12:38:37 +0000
commitc15717285d2157a603bb1b130b26d7baa549be7e (patch)
tree56dc8346b22bb2660eecd3bc086d263ac6d67326 /src/os/unix/ngx_readv_chain.c
parente12fbfe82a176cd386cdcecfeabf43ac8fd870a4 (diff)
downloadnginx-release-0.1.25.tar.gz
nginx-release-0.1.25.zip
nginx-0.1.25-RELEASE importrelease-0.1.25
*) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
Diffstat (limited to 'src/os/unix/ngx_readv_chain.c')
-rw-r--r--src/os/unix/ngx_readv_chain.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index 7c57b7abe..47d8f3b7c 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -9,16 +9,20 @@
#include <ngx_event.h>
+#define NGX_IOVS 16
+
+
#if (NGX_HAVE_KQUEUE)
-ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+ssize_t
+ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
{
u_char *prev;
ssize_t n, size;
ngx_err_t err;
- ngx_array_t io;
+ ngx_array_t vec;
ngx_event_t *rev;
- struct iovec *iov;
+ struct iovec *iov, iovs[NGX_IOVS];
rev = c->read;
@@ -53,7 +57,11 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
iov = NULL;
size = 0;
- ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
+ vec.elts = iovs;
+ vec.nelts = 0;
+ vec.size = sizeof(struct iovec);
+ vec.nalloc = NGX_IOVS;
+ vec.pool = c->pool;
/* coalesce the neighbouring bufs */
@@ -62,7 +70,11 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
iov->iov_len += chain->buf->end - chain->buf->last;
} else {
- ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+ iov = ngx_array_push(&vec);
+ if (iov == NULL) {
+ return NGX_ERROR;
+ }
+
iov->iov_base = (void *) chain->buf->last;
iov->iov_len = chain->buf->end - chain->buf->last;
}
@@ -73,12 +85,12 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "readv: %d, last:%d", io.nelts, iov->iov_len);
+ "readv: %d, last:%d", vec.nelts, iov->iov_len);
rev = c->read;
do {
- n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
+ n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
if (n >= 0) {
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
@@ -138,20 +150,25 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
#else /* ! NGX_HAVE_KQUEUE */
-ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+ssize_t
+ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
{
u_char *prev;
ssize_t n, size;
ngx_err_t err;
- ngx_array_t io;
+ ngx_array_t vec;
ngx_event_t *rev;
- struct iovec *iov;
+ struct iovec *iov, iovs[NGX_IOVS];
prev = NULL;
iov = NULL;
size = 0;
- ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
+ vec.elts = iovs;
+ vec.nelts = 0;
+ vec.size = sizeof(struct iovec);
+ vec.nalloc = NGX_IOVS;
+ vec.pool = c->pool;
/* coalesce the neighbouring bufs */
@@ -160,7 +177,11 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
iov->iov_len += chain->buf->end - chain->buf->last;
} else {
- ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+ iov = ngx_array_push(&vec);
+ if (iov == NULL) {
+ return NGX_ERROR;
+ }
+
iov->iov_base = chain->buf->last;
iov->iov_len = chain->buf->end - chain->buf->last;
}
@@ -171,12 +192,12 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "readv: %d:%d", io.nelts, iov->iov_len);
+ "readv: %d:%d", vec.nelts, iov->iov_len);
rev = c->read;
do {
- n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
+ n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
if (n == 0) {
rev->ready = 0;