diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2012-04-17 09:13:15 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2012-04-17 09:13:15 +0000 |
commit | 578c02f3a1fda0ad43277af2af022c24f2e74104 (patch) | |
tree | cb4b16e5f43499cb817b08e32e8d70c33395fc3e /src/os/unix/ngx_freebsd_sendfile_chain.c | |
parent | 96d73e291f77152d6494f7cb969ec0cd3bb74215 (diff) | |
download | nginx-578c02f3a1fda0ad43277af2af022c24f2e74104.tar.gz nginx-578c02f3a1fda0ad43277af2af022c24f2e74104.zip |
IOV_MAX handling microoptimization.
We now stop on IOV_MAX iovec entries only if we are going to add new one,
i.e. next buffer can't be coalesced into last iovec.
This also fixes incorrect checks for trailer creation on FreeBSD and
Mac OS X, header.nelts was checked instead of trailer.nelts.
Diffstat (limited to 'src/os/unix/ngx_freebsd_sendfile_chain.c')
-rw-r--r-- | src/os/unix/ngx_freebsd_sendfile_chain.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c index 724bb0d70..f58b5c20f 100644 --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -107,10 +107,8 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) prev = NULL; iov = NULL; - for (cl = in; - cl && header.nelts < IOV_MAX && send < limit; - cl = cl->next) - { + for (cl = in; cl && send < limit; cl = cl->next) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -129,6 +127,10 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) iov->iov_len += (size_t) size; } else { + if (header.nelts >= IOV_MAX){ + break; + } + iov = ngx_array_push(&header); if (iov == NULL) { return NGX_CHAIN_ERROR; @@ -183,7 +185,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) prev = NULL; iov = NULL; - while (cl && header.nelts < IOV_MAX && send < limit) { + while (cl && send < limit) { if (ngx_buf_special(cl->buf)) { cl = cl->next; @@ -204,6 +206,10 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) iov->iov_len += (size_t) size; } else { + if (trailer.nelts >= IOV_MAX){ + break; + } + iov = ngx_array_push(&trailer); if (iov == NULL) { return NGX_CHAIN_ERROR; |