comparison src/http/modules/perl/nginx.xs @ 613:c73c5c58c619 release-0.3.28

nginx-0.3.28-RELEASE import *) Feature: the "restrict_host_names" directive was canceled. *) Feature: the --with-cpu-opt=ppc64 configuration parameter. *) Bugfix: on some condition the proxied connection with a client was terminated prematurely. Thanks to Vladimir Shutoff. *) Bugfix: the "X-Accel-Limit-Rate" header line was not taken into account if the request was redirected using the "X-Accel-Redirect" header line. *) Bugfix: the "post_action" directive ran only after a successful completion of a request. *) Bugfix: the proxied response body generated by the "post_action" directive was transferred to a client.
author Igor Sysoev <igor@sysoev.ru>
date Thu, 16 Feb 2006 15:26:46 +0000
parents 858700ae46b4
children 51b27717f140
comparison
equal deleted inserted replaced
612:182bfe05e2c3 613:c73c5c58c619
413 OUTPUT: 413 OUTPUT:
414 RETVAL 414 RETVAL
415 415
416 416
417 int 417 int
418 sendfile(r, filename) 418 sendfile(r, filename, offset = -1, bytes = 0)
419 nginx r 419 nginx r
420 char *filename 420 char *filename
421 int offset;
422 size_t bytes;
421 423
422 PREINIT: 424 PREINIT:
423 425
424 ngx_fd_t fd; 426 ngx_fd_t fd;
425 ngx_buf_t *b; 427 ngx_buf_t *b;
458 ngx_open_file_n " \"%s\" failed", filename); 460 ngx_open_file_n " \"%s\" failed", filename);
459 RETVAL = NGX_ERROR; 461 RETVAL = NGX_ERROR;
460 goto done; 462 goto done;
461 } 463 }
462 464
463 if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) { 465 if (offset == -1) {
464 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, 466 offset = 0;
465 ngx_fd_info_n " \"%s\" failed", filename); 467 }
466 468
467 if (ngx_close_file(fd) == NGX_FILE_ERROR) { 469 if (bytes == 0) {
468 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, 470 if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
469 ngx_close_file_n " \"%s\" failed", filename); 471 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
470 } 472 ngx_fd_info_n " \"%s\" failed", filename);
471 473
472 RETVAL = NGX_ERROR; 474 if (ngx_close_file(fd) == NGX_FILE_ERROR) {
473 goto done; 475 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
476 ngx_close_file_n " \"%s\" failed", filename);
477 }
478
479 RETVAL = NGX_ERROR;
480 goto done;
481
482 }
483
484 bytes = ngx_file_size(&fi) - offset;
474 } 485 }
475 486
476 cln->handler = ngx_pool_cleanup_file; 487 cln->handler = ngx_pool_cleanup_file;
477 clnf = cln->data; 488 clnf = cln->data;
478 489
479 clnf->fd = fd; 490 clnf->fd = fd;
480 clnf->name = (u_char *) ""; 491 clnf->name = (u_char *) "";
481 clnf->log = r->pool->log; 492 clnf->log = r->pool->log;
482 493
483 b->in_file = 1; 494 b->in_file = 1;
484 b->file_pos = 0; 495
485 b->file_last = ngx_file_size(&fi); 496 b->file_pos = offset;
497 b->file_last = offset + bytes;
486 498
487 b->file->fd = fd; 499 b->file->fd = fd;
488 b->file->log = r->connection->log; 500 b->file->log = r->connection->log;
489 501
490 RETVAL = ngx_http_perl_output(r, b); 502 RETVAL = ngx_http_perl_output(r, b);