comparison src/http/ngx_http_upstream.c @ 5848:106a8bfa4f42

Upstream: fixed file buffers reinit in ngx_http_upstream_reinit(). Previously, a file buffer start position was reset to the file start. Now it's reset to the previous file buffer end. This fixes reinitialization of requests having multiple successive parts of a single file. Such requests are generated by fastcgi module.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 18 Sep 2014 16:37:16 +0400
parents d09b689911ac
children fd283aa92e04
comparison
equal deleted inserted replaced
5847:52b4984d2b3c 5848:106a8bfa4f42
1568 1568
1569 1569
1570 static ngx_int_t 1570 static ngx_int_t
1571 ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u) 1571 ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u)
1572 { 1572 {
1573 off_t file_pos;
1573 ngx_chain_t *cl; 1574 ngx_chain_t *cl;
1574 1575
1575 if (u->reinit_request(r) != NGX_OK) { 1576 if (u->reinit_request(r) != NGX_OK) {
1576 return NGX_ERROR; 1577 return NGX_ERROR;
1577 } 1578 }
1589 return NGX_ERROR; 1590 return NGX_ERROR;
1590 } 1591 }
1591 1592
1592 /* reinit the request chain */ 1593 /* reinit the request chain */
1593 1594
1595 file_pos = 0;
1596
1594 for (cl = u->request_bufs; cl; cl = cl->next) { 1597 for (cl = u->request_bufs; cl; cl = cl->next) {
1595 cl->buf->pos = cl->buf->start; 1598 cl->buf->pos = cl->buf->start;
1596 cl->buf->file_pos = 0; 1599
1600 /* there is at most one file */
1601
1602 if (cl->buf->in_file) {
1603 cl->buf->file_pos = file_pos;
1604 file_pos = cl->buf->file_last;
1605 }
1597 } 1606 }
1598 1607
1599 /* reinit the subrequest's ngx_output_chain() context */ 1608 /* reinit the subrequest's ngx_output_chain() context */
1600 1609
1601 if (r->request_body && r->request_body->temp_file 1610 if (r->request_body && r->request_body->temp_file