[nginx] Refactored ngx_solaris_sendfilev_chain().
Valentin Bartenev
vbart at nginx.com
Wed Nov 19 18:19:04 UTC 2014
details: http://hg.nginx.org/nginx/rev/4dd67e5d958e
branches:
changeset: 5914:4dd67e5d958e
user: Valentin Bartenev <vbart at nginx.com>
date: Wed Nov 19 21:17:11 2014 +0300
description:
Refactored ngx_solaris_sendfilev_chain().
Though ngx_solaris_sendfilev_chain() shouldn't suffer from the problem mentioned
in d1bde5c3c5d2 since currently IOV_MAX on Solaris is 16, but this follows the
change from 3d5717550371 in order to make the code look similar to other systems
and potentially eliminates the problem in the future.
diffstat:
src/os/unix/ngx_solaris_sendfilev_chain.c | 25 +++++++------------------
1 files changed, 7 insertions(+), 18 deletions(-)
diffs (77 lines):
diff -r 8e903522c17a -r 4dd67e5d958e src/os/unix/ngx_solaris_sendfilev_chain.c
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c Tue Oct 07 11:38:57 2014 +0400
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c Wed Nov 19 21:17:11 2014 +0300
@@ -48,8 +48,8 @@ ngx_solaris_sendfilev_chain(ngx_connecti
ssize_t n;
ngx_int_t eintr;
ngx_err_t err;
+ ngx_uint_t nsfv;
sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS];
- ngx_array_t vec;
ngx_event_t *wev;
ngx_chain_t *cl;
@@ -73,11 +73,6 @@ ngx_solaris_sendfilev_chain(ngx_connecti
send = 0;
- vec.elts = sfvs;
- vec.size = sizeof(sendfilevec_t);
- vec.nalloc = NGX_SENDFILEVECS;
- vec.pool = c->pool;
-
for ( ;; ) {
fd = SFV_FD_SELF;
prev = NULL;
@@ -87,7 +82,7 @@ ngx_solaris_sendfilev_chain(ngx_connecti
sent = 0;
prev_send = send;
- vec.nelts = 0;
+ nsfv = 0;
/* create the sendfilevec and coalesce the neighbouring bufs */
@@ -110,14 +105,11 @@ ngx_solaris_sendfilev_chain(ngx_connecti
sfv->sfv_len += (size_t) size;
} else {
- if (vec.nelts >= IOV_MAX) {
+ if (nsfv == NGX_SENDFILEVECS) {
break;
}
- sfv = ngx_array_push(&vec);
- if (sfv == NULL) {
- return NGX_CHAIN_ERROR;
- }
+ sfv = &sfvs[nsfv++];
sfv->sfv_fd = SFV_FD_SELF;
sfv->sfv_flag = 0;
@@ -148,14 +140,11 @@ ngx_solaris_sendfilev_chain(ngx_connecti
sfv->sfv_len += (size_t) size;
} else {
- if (vec.nelts >= IOV_MAX) {
+ if (nsfv == NGX_SENDFILEVECS) {
break;
}
- sfv = ngx_array_push(&vec);
- if (sfv == NULL) {
- return NGX_CHAIN_ERROR;
- }
+ sfv = &sfvs[nsfv++];
fd = cl->buf->file->fd;
sfv->sfv_fd = fd;
@@ -169,7 +158,7 @@ ngx_solaris_sendfilev_chain(ngx_connecti
}
}
- n = sendfilev(c->fd, vec.elts, vec.nelts, &sent);
+ n = sendfilev(c->fd, sfvs, nsfv, &sent);
if (n == -1) {
err = ngx_errno;
More information about the nginx-devel
mailing list