comparison src/os/unix/ngx_freebsd_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 188481078faf
comparison
equal deleted inserted replaced
5319:50f531a55b73 5320:ad137a80919f
366 complete = 1; 366 complete = 1;
367 } 367 }
368 368
369 c->sent += sent; 369 c->sent += sent;
370 370
371 for (cl = in; cl; cl = cl->next) { 371 for ( /* void */ ; in; in = in->next) {
372 372
373 if (ngx_buf_special(cl->buf)) { 373 if (ngx_buf_special(in->buf)) {
374 continue; 374 continue;
375 } 375 }
376 376
377 if (sent == 0) { 377 if (sent == 0) {
378 break; 378 break;
379 } 379 }
380 380
381 size = ngx_buf_size(cl->buf); 381 size = ngx_buf_size(in->buf);
382 382
383 if (sent >= size) { 383 if (sent >= size) {
384 sent -= size; 384 sent -= size;
385 385
386 if (ngx_buf_in_memory(cl->buf)) { 386 if (ngx_buf_in_memory(in->buf)) {
387 cl->buf->pos = cl->buf->last; 387 in->buf->pos = in->buf->last;
388 } 388 }
389 389
390 if (cl->buf->in_file) { 390 if (in->buf->in_file) {
391 cl->buf->file_pos = cl->buf->file_last; 391 in->buf->file_pos = in->buf->file_last;
392 } 392 }
393 393
394 continue; 394 continue;
395 } 395 }
396 396
397 if (ngx_buf_in_memory(cl->buf)) { 397 if (ngx_buf_in_memory(in->buf)) {
398 cl->buf->pos += (size_t) sent; 398 in->buf->pos += (size_t) sent;
399 } 399 }
400 400
401 if (cl->buf->in_file) { 401 if (in->buf->in_file) {
402 cl->buf->file_pos += sent; 402 in->buf->file_pos += sent;
403 } 403 }
404 404
405 break; 405 break;
406 } 406 }
407 407
408 #if (NGX_HAVE_AIO_SENDFILE) 408 #if (NGX_HAVE_AIO_SENDFILE)
409 if (c->busy_sendfile) { 409 if (c->busy_sendfile) {
410 return cl; 410 return in;
411 } 411 }
412 #endif 412 #endif
413 413
414 if (eagain) { 414 if (eagain) {
415 415
419 * return EAGAIN right away and would not send anything. 419 * return EAGAIN right away and would not send anything.
420 * We use it as a hint. 420 * We use it as a hint.
421 */ 421 */
422 422
423 wev->ready = 0; 423 wev->ready = 0;
424 return cl; 424 return in;
425 } 425 }
426 426
427 if (eintr) { 427 if (eintr) {
428 continue; 428 continue;
429 } 429 }
430 430
431 if (!complete) { 431 if (!complete) {
432 wev->ready = 0; 432 wev->ready = 0;
433 return cl; 433 return in;
434 } 434 }
435 435
436 if (send >= limit || cl == NULL) { 436 if (send >= limit || in == NULL) {
437 return cl; 437 return in;
438 } 438 }
439
440 in = cl;
441 } 439 }
442 } 440 }