Klaus Demo nginx / b993b9d
Merge of r4221, r4222: Fixed unix ngx_write_chain_to_file() to return total bytes written. Previously result of last iteration's writev() was returned. This was unnoticed as return value was only used if chain contained only one or two buffers. Maxim Dounin 10 years ago
1 changed file(s) with 14 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
152152 {
153153 u_char *prev;
154154 size_t size;
155 ssize_t n;
155 ssize_t total, n;
156156 ngx_array_t vec;
157157 struct iovec *iov, iovs[NGX_IOVS];
158158
163163 (size_t) (cl->buf->last - cl->buf->pos),
164164 offset);
165165 }
166
167 total = 0;
166168
167169 vec.elts = iovs;
168170 vec.size = sizeof(struct iovec);
201203
202204 if (vec.nelts == 1) {
203205 iov = vec.elts;
204 return ngx_write_file(file, (u_char *) iov[0].iov_base,
205 iov[0].iov_len, offset);
206
207 n = ngx_write_file(file, (u_char *) iov[0].iov_base,
208 iov[0].iov_len, offset);
209
210 if (n == NGX_ERROR) {
211 return n;
212 }
213
214 return total + n;
206215 }
207216
208217 if (file->sys_offset != offset) {
232241
233242 file->sys_offset += n;
234243 file->offset += n;
244 total += n;
235245
236246 } while (cl);
237247
238 return n;
248 return total;
239249 }
240250
241251