Mercurial > hg > nginx
comparison src/http/modules/ngx_http_fastcgi_module.c @ 5028:44025ae9fc67
FastCGI: proper handling of split fastcgi end request.
If fastcgi end request record was split between several network packets,
with fastcgi_keep_conn it was possible that connection was saved in incorrect
state (e.g. with padding bytes not yet read).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 01 Feb 2013 14:41:50 +0000 |
parents | 2ab25df19dc6 |
children | 05c53652e7b4 b246018860a2 |
comparison
equal
deleted
inserted
replaced
5027:2ab25df19dc6 | 5028:44025ae9fc67 |
---|---|
1699 | 1699 |
1700 continue; | 1700 continue; |
1701 } | 1701 } |
1702 | 1702 |
1703 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | 1703 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { |
1704 f->state = ngx_http_fastcgi_st_padding; | |
1705 | |
1706 p->upstream_done = 1; | |
1707 | |
1708 if (flcf->keep_conn) { | |
1709 r->upstream->keepalive = 1; | |
1710 } | |
1711 | 1704 |
1712 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | 1705 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, |
1713 "http fastcgi sent end request"); | 1706 "http fastcgi sent end request"); |
1714 | 1707 |
1708 if (!flcf->keep_conn) { | |
1709 p->upstream_done = 1; | |
1710 break; | |
1711 } | |
1712 | |
1715 continue; | 1713 continue; |
1716 } | 1714 } |
1717 } | 1715 } |
1718 | 1716 |
1719 | 1717 |
1720 if (f->state == ngx_http_fastcgi_st_padding) { | 1718 if (f->state == ngx_http_fastcgi_st_padding) { |
1719 | |
1720 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | |
1721 | |
1722 if (f->pos + f->padding < f->last) { | |
1723 p->upstream_done = 1; | |
1724 break; | |
1725 } | |
1726 | |
1727 if (f->pos + f->padding == f->last) { | |
1728 p->upstream_done = 1; | |
1729 r->upstream->keepalive = 1; | |
1730 break; | |
1731 } | |
1732 | |
1733 f->padding -= f->last - f->pos; | |
1734 | |
1735 break; | |
1736 } | |
1721 | 1737 |
1722 if (f->pos + f->padding < f->last) { | 1738 if (f->pos + f->padding < f->last) { |
1723 f->state = ngx_http_fastcgi_st_version; | 1739 f->state = ngx_http_fastcgi_st_version; |
1724 f->pos += f->padding; | 1740 f->pos += f->padding; |
1725 | 1741 |
1773 } else { | 1789 } else { |
1774 f->state = ngx_http_fastcgi_st_padding; | 1790 f->state = ngx_http_fastcgi_st_padding; |
1775 } | 1791 } |
1776 | 1792 |
1777 continue; | 1793 continue; |
1794 } | |
1795 | |
1796 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | |
1797 | |
1798 if (f->pos + f->length <= f->last) { | |
1799 f->state = ngx_http_fastcgi_st_padding; | |
1800 f->pos += f->length; | |
1801 | |
1802 continue; | |
1803 } | |
1804 | |
1805 f->length -= f->last - f->pos; | |
1806 | |
1807 break; | |
1778 } | 1808 } |
1779 | 1809 |
1780 | 1810 |
1781 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | 1811 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ |
1782 | 1812 |