comparison src/os/unix/ngx_writev_chain.c @ 4596:089cc5154c1e

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 17 Apr 2012 09:13:15 +0000
parents 6cd5d4a279d6
children f9c83484d9ce
comparison
equal deleted inserted replaced
4595:6cd5d4a279d6 4596:089cc5154c1e
69 69
70 vec.nelts = 0; 70 vec.nelts = 0;
71 71
72 /* create the iovec and coalesce the neighbouring bufs */ 72 /* create the iovec and coalesce the neighbouring bufs */
73 73
74 for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next) 74 for (cl = in; cl && send < limit; cl = cl->next) {
75 { 75
76 if (ngx_buf_special(cl->buf)) { 76 if (ngx_buf_special(cl->buf)) {
77 continue; 77 continue;
78 } 78 }
79 79
80 #if 1 80 #if 1
91 91
92 if (prev == cl->buf->pos) { 92 if (prev == cl->buf->pos) {
93 iov->iov_len += size; 93 iov->iov_len += size;
94 94
95 } else { 95 } else {
96 if (vec.nelts >= IOV_MAX) {
97 break;
98 }
99
96 iov = ngx_array_push(&vec); 100 iov = ngx_array_push(&vec);
97 if (iov == NULL) { 101 if (iov == NULL) {
98 return NGX_CHAIN_ERROR; 102 return NGX_CHAIN_ERROR;
99 } 103 }
100 104