Mercurial > hg > nginx-quic
comparison src/os/unix/ngx_darwin_sendfile_chain.c @ 5320:ad137a80919f
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
In ngx_*_sendfile_chain() when calculating pointer to a first
non-zero sized buf, use "in" as iterator. This fixes processing
of zero sized buf(s) after EINTR. Otherwise function can return
zero sized buf to caller, and later ngx_http_write_filter()
logs warning.
author | Gleb Smirnoff <glebius@nginx.com> |
---|---|
date | Thu, 08 Aug 2013 15:06:39 +0400 |
parents | 089cc5154c1e |
children | 675bda8dcfdb |
comparison
equal
deleted
inserted
replaced
5319:50f531a55b73 | 5320:ad137a80919f |
---|---|
315 complete = 1; | 315 complete = 1; |
316 } | 316 } |
317 | 317 |
318 c->sent += sent; | 318 c->sent += sent; |
319 | 319 |
320 for (cl = in; cl; cl = cl->next) { | 320 for ( /* void */ ; in; in = in->next) { |
321 | 321 |
322 if (ngx_buf_special(cl->buf)) { | 322 if (ngx_buf_special(in->buf)) { |
323 continue; | 323 continue; |
324 } | 324 } |
325 | 325 |
326 if (sent == 0) { | 326 if (sent == 0) { |
327 break; | 327 break; |
328 } | 328 } |
329 | 329 |
330 size = ngx_buf_size(cl->buf); | 330 size = ngx_buf_size(in->buf); |
331 | 331 |
332 if (sent >= size) { | 332 if (sent >= size) { |
333 sent -= size; | 333 sent -= size; |
334 | 334 |
335 if (ngx_buf_in_memory(cl->buf)) { | 335 if (ngx_buf_in_memory(in->buf)) { |
336 cl->buf->pos = cl->buf->last; | 336 in->buf->pos = in->buf->last; |
337 } | 337 } |
338 | 338 |
339 if (cl->buf->in_file) { | 339 if (in->buf->in_file) { |
340 cl->buf->file_pos = cl->buf->file_last; | 340 in->buf->file_pos = in->buf->file_last; |
341 } | 341 } |
342 | 342 |
343 continue; | 343 continue; |
344 } | 344 } |
345 | 345 |
346 if (ngx_buf_in_memory(cl->buf)) { | 346 if (ngx_buf_in_memory(in->buf)) { |
347 cl->buf->pos += (size_t) sent; | 347 in->buf->pos += (size_t) sent; |
348 } | 348 } |
349 | 349 |
350 if (cl->buf->in_file) { | 350 if (in->buf->in_file) { |
351 cl->buf->file_pos += sent; | 351 in->buf->file_pos += sent; |
352 } | 352 } |
353 | 353 |
354 break; | 354 break; |
355 } | 355 } |
356 | 356 |
358 continue; | 358 continue; |
359 } | 359 } |
360 | 360 |
361 if (!complete) { | 361 if (!complete) { |
362 wev->ready = 0; | 362 wev->ready = 0; |
363 return cl; | 363 return in; |
364 } | 364 } |
365 | 365 |
366 if (send >= limit || cl == NULL) { | 366 if (send >= limit || in == NULL) { |
367 return cl; | 367 return in; |
368 } | 368 } |
369 | |
370 in = cl; | |
371 } | 369 } |
372 } | 370 } |