aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_solaris_sendfilev_chain.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-09-16 16:10:13 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-09-16 16:10:13 +0000
commit95d00c435ace44f782bbb70dd5eac7fb1f9b8610 (patch)
tree53799251b1b9c7d27eb1a63e5020daa5c2baba4e /src/os/unix/ngx_solaris_sendfilev_chain.c
parent85cccfba8d0c33e7f3546e630f67c1a1940c8d1f (diff)
downloadnginx-95d00c435ace44f782bbb70dd5eac7fb1f9b8610.tar.gz
nginx-95d00c435ace44f782bbb70dd5eac7fb1f9b8610.zip
nginx-0.0.11-2004-09-16-20:10:13 import
Diffstat (limited to 'src/os/unix/ngx_solaris_sendfilev_chain.c')
-rw-r--r--src/os/unix/ngx_solaris_sendfilev_chain.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c
index 07a8a8d4e..d249e8186 100644
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -9,6 +9,9 @@
#include <ngx_event.h>
+#define NGX_SENDFILEVECS 16
+
+
ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
off_t limit)
{
@@ -19,7 +22,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
ssize_t n;
ngx_int_t eintr, complete;
ngx_err_t err;
- sendfilevec_t *sfv;
+ sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS];
ngx_array_t vec;
ngx_event_t *wev;
ngx_chain_t *cl, *tail;
@@ -33,6 +36,11 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
send = 0;
complete = 0;
+ vec.elts = sfvs;
+ vec.size = sizeof(sendfilevec_t);
+ vec.nalloc = NGX_SENDFILEVECS;
+ vec.pool = c->pool;
+
for ( ;; ) {
fd = SFV_FD_SELF;
prev = NULL;
@@ -42,8 +50,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sent = 0;
sprev = send;
- ngx_init_array(vec, c->pool, 10, sizeof(sendfilevec_t),
- NGX_CHAIN_ERROR);
+ vec.nelts = 0;
/* create the sendfilevec and coalesce the neighbouring bufs */
@@ -66,7 +73,10 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_len += size;
} else {
- ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR);
+ if (!(sfv = ngx_array_push(&vec))) {
+ return NGX_CHAIN_ERROR;
+ }
+
sfv->sfv_fd = SFV_FD_SELF;
sfv->sfv_flag = 0;
sfv->sfv_off = (off_t) (uintptr_t) cl->buf->pos;
@@ -96,7 +106,10 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_len += size;
} else {
- ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR);
+ if (!(sfv = ngx_array_push(&vec))) {
+ return NGX_CHAIN_ERROR;
+ }
+
fd = cl->buf->file->fd;
sfv->sfv_fd = fd;
sfv->sfv_flag = 0;