Mercurial > hg > nginx
comparison src/http/modules/ngx_http_fastcgi_module.c @ 5027:2ab25df19dc6
FastCGI: unconditional state transitions.
Checks for f->padding before state transitions make code hard to follow,
remove them and make sure we always do another loop iteration after
f->state is set to ngx_http_fastcgi_st_padding.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 01 Feb 2013 14:41:07 +0000 |
parents | f3f3083f1253 |
children | 44025ae9fc67 |
comparison
equal
deleted
inserted
replaced
5026:f3f3083f1253 | 5027:2ab25df19dc6 |
---|---|
1354 | 1354 |
1355 return NGX_AGAIN; | 1355 return NGX_AGAIN; |
1356 } | 1356 } |
1357 | 1357 |
1358 } else { | 1358 } else { |
1359 if (f->padding) { | 1359 f->state = ngx_http_fastcgi_st_padding; |
1360 f->state = ngx_http_fastcgi_st_padding; | |
1361 } else { | |
1362 f->state = ngx_http_fastcgi_st_version; | |
1363 } | |
1364 } | 1360 } |
1365 | 1361 |
1366 continue; | 1362 continue; |
1367 } | 1363 } |
1368 | 1364 |
1595 } | 1591 } |
1596 | 1592 |
1597 f->length -= u->buffer.pos - start; | 1593 f->length -= u->buffer.pos - start; |
1598 | 1594 |
1599 if (f->length == 0) { | 1595 if (f->length == 0) { |
1600 if (f->padding) { | 1596 f->state = ngx_http_fastcgi_st_padding; |
1601 f->state = ngx_http_fastcgi_st_padding; | |
1602 } else { | |
1603 f->state = ngx_http_fastcgi_st_version; | |
1604 } | |
1605 } | 1597 } |
1606 | 1598 |
1607 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | 1599 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
1608 return NGX_OK; | 1600 return NGX_OK; |
1609 } | 1601 } |
1694 if (rc == NGX_ERROR) { | 1686 if (rc == NGX_ERROR) { |
1695 return NGX_ERROR; | 1687 return NGX_ERROR; |
1696 } | 1688 } |
1697 | 1689 |
1698 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { | 1690 if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { |
1699 | 1691 f->state = ngx_http_fastcgi_st_padding; |
1700 if (f->padding) { | |
1701 f->state = ngx_http_fastcgi_st_padding; | |
1702 } else { | |
1703 f->state = ngx_http_fastcgi_st_version; | |
1704 } | |
1705 | 1692 |
1706 if (!flcf->keep_conn) { | 1693 if (!flcf->keep_conn) { |
1707 p->upstream_done = 1; | 1694 p->upstream_done = 1; |
1708 } | 1695 } |
1709 | 1696 |
1712 | 1699 |
1713 continue; | 1700 continue; |
1714 } | 1701 } |
1715 | 1702 |
1716 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { | 1703 if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) { |
1717 | 1704 f->state = ngx_http_fastcgi_st_padding; |
1718 if (f->padding) { | |
1719 f->state = ngx_http_fastcgi_st_padding; | |
1720 } else { | |
1721 f->state = ngx_http_fastcgi_st_version; | |
1722 } | |
1723 | 1705 |
1724 p->upstream_done = 1; | 1706 p->upstream_done = 1; |
1725 | 1707 |
1726 if (flcf->keep_conn) { | 1708 if (flcf->keep_conn) { |
1727 r->upstream->keepalive = 1; | 1709 r->upstream->keepalive = 1; |
1728 } | 1710 } |
1729 | 1711 |
1730 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, | 1712 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, |
1731 "http fastcgi sent end request"); | 1713 "http fastcgi sent end request"); |
1732 | 1714 |
1733 break; | 1715 continue; |
1734 } | 1716 } |
1735 } | 1717 } |
1736 | 1718 |
1737 | 1719 |
1738 if (f->state == ngx_http_fastcgi_st_padding) { | 1720 if (f->state == ngx_http_fastcgi_st_padding) { |
1787 ngx_log_error(NGX_LOG_ERR, p->log, 0, | 1769 ngx_log_error(NGX_LOG_ERR, p->log, 0, |
1788 "FastCGI sent in stderr: \"%*s\"", | 1770 "FastCGI sent in stderr: \"%*s\"", |
1789 m + 1 - msg, msg); | 1771 m + 1 - msg, msg); |
1790 | 1772 |
1791 } else { | 1773 } else { |
1792 if (f->padding) { | 1774 f->state = ngx_http_fastcgi_st_padding; |
1793 f->state = ngx_http_fastcgi_st_padding; | |
1794 } else { | |
1795 f->state = ngx_http_fastcgi_st_version; | |
1796 } | |
1797 } | 1775 } |
1798 | 1776 |
1799 continue; | 1777 continue; |
1800 } | 1778 } |
1801 | 1779 |
1850 /* STUB */ b->num = buf->num; | 1828 /* STUB */ b->num = buf->num; |
1851 | 1829 |
1852 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, | 1830 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
1853 "input buf #%d %p", b->num, b->pos); | 1831 "input buf #%d %p", b->num, b->pos); |
1854 | 1832 |
1855 if (f->pos + f->length < f->last) { | 1833 if (f->pos + f->length <= f->last) { |
1856 | 1834 f->state = ngx_http_fastcgi_st_padding; |
1857 if (f->padding) { | |
1858 f->state = ngx_http_fastcgi_st_padding; | |
1859 } else { | |
1860 f->state = ngx_http_fastcgi_st_version; | |
1861 } | |
1862 | |
1863 f->pos += f->length; | 1835 f->pos += f->length; |
1864 b->last = f->pos; | 1836 b->last = f->pos; |
1865 | 1837 |
1866 continue; | 1838 continue; |
1867 } | |
1868 | |
1869 if (f->pos + f->length == f->last) { | |
1870 | |
1871 if (f->padding) { | |
1872 f->state = ngx_http_fastcgi_st_padding; | |
1873 } else { | |
1874 f->state = ngx_http_fastcgi_st_version; | |
1875 } | |
1876 | |
1877 b->last = f->last; | |
1878 | |
1879 break; | |
1880 } | 1839 } |
1881 | 1840 |
1882 f->length -= f->last - f->pos; | 1841 f->length -= f->last - f->pos; |
1883 | 1842 |
1884 b->last = f->last; | 1843 b->last = f->last; |