Klaus Demo nginx / 578c02f
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. Maxim Dounin 10 years ago
5 changed file(s) with 44 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
102102 prev = NULL;
103103 iov = NULL;
104104
105 for (cl = in;
106 cl && header.nelts < IOV_MAX && send < limit;
107 cl = cl->next)
108 {
105 for (cl = in; cl && send < limit; cl = cl->next) {
106
109107 if (ngx_buf_special(cl->buf)) {
110108 continue;
111109 }
124122 iov->iov_len += (size_t) size;
125123
126124 } else {
125 if (header.nelts >= IOV_MAX) {
126 break;
127 }
128
127129 iov = ngx_array_push(&header);
128130 if (iov == NULL) {
129131 return NGX_CHAIN_ERROR;
177179 prev = NULL;
178180 iov = NULL;
179181
180 while (cl && header.nelts < IOV_MAX && send < limit) {
182 while (cl && send < limit) {
181183
182184 if (ngx_buf_special(cl->buf)) {
183185 cl = cl->next;
198200 iov->iov_len += (size_t) size;
199201
200202 } else {
203 if (trailer.nelts >= IOV_MAX) {
204 break;
205 }
206
201207 iov = ngx_array_push(&trailer);
202208 if (iov == NULL) {
203209 return NGX_CHAIN_ERROR;
106106 prev = NULL;
107107 iov = NULL;
108108
109 for (cl = in;
110 cl && header.nelts < IOV_MAX && send < limit;
111 cl = cl->next)
112 {
109 for (cl = in; cl && send < limit; cl = cl->next) {
110
113111 if (ngx_buf_special(cl->buf)) {
114112 continue;
115113 }
128126 iov->iov_len += (size_t) size;
129127
130128 } else {
129 if (header.nelts >= IOV_MAX){
130 break;
131 }
132
131133 iov = ngx_array_push(&header);
132134 if (iov == NULL) {
133135 return NGX_CHAIN_ERROR;
182184 prev = NULL;
183185 iov = NULL;
184186
185 while (cl && header.nelts < IOV_MAX && send < limit) {
187 while (cl && send < limit) {
186188
187189 if (ngx_buf_special(cl->buf)) {
188190 cl = cl->next;
203205 iov->iov_len += (size_t) size;
204206
205207 } else {
208 if (trailer.nelts >= IOV_MAX){
209 break;
210 }
211
206212 iov = ngx_array_push(&trailer);
207213 if (iov == NULL) {
208214 return NGX_CHAIN_ERROR;
8888
8989 /* create the iovec and coalesce the neighbouring bufs */
9090
91 for (cl = in;
92 cl && header.nelts < IOV_MAX && send < limit;
93 cl = cl->next)
94 {
91 for (cl = in; cl && send < limit; cl = cl->next) {
92
9593 if (ngx_buf_special(cl->buf)) {
9694 continue;
9795 }
131129 iov->iov_len += (size_t) size;
132130
133131 } else {
132 if (header.nelts >= IOV_MAX) {
133 break;
134 }
135
134136 iov = ngx_array_push(&header);
135137 if (iov == NULL) {
136138 return NGX_CHAIN_ERROR;
9393
9494 /* create the sendfilevec and coalesce the neighbouring bufs */
9595
96 for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next)
97 {
96 for (cl = in; cl && send < limit; cl = cl->next) {
97
9898 if (ngx_buf_special(cl->buf)) {
9999 continue;
100100 }
112112 sfv->sfv_len += (size_t) size;
113113
114114 } else {
115 if (vec.nelts >= IOV_MAX) {
116 break;
117 }
118
115119 sfv = ngx_array_push(&vec);
116120 if (sfv == NULL) {
117121 return NGX_CHAIN_ERROR;
146150 sfv->sfv_len += (size_t) size;
147151
148152 } else {
153 if (vec.nelts >= IOV_MAX) {
154 break;
155 }
156
149157 sfv = ngx_array_push(&vec);
150158 if (sfv == NULL) {
151159 return NGX_CHAIN_ERROR;
7070
7171 /* create the iovec and coalesce the neighbouring bufs */
7272
73 for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next)
74 {
73 for (cl = in; cl && send < limit; cl = cl->next) {
74
7575 if (ngx_buf_special(cl->buf)) {
7676 continue;
7777 }
9292 iov->iov_len += size;
9393
9494 } else {
95 if (vec.nelts >= IOV_MAX) {
96 break;
97 }
98
9599 iov = ngx_array_push(&vec);
96100 if (iov == NULL) {
97101 return NGX_CHAIN_ERROR;