Mercurial > hg > nginx-quic
comparison src/http/ngx_http_request.c @ 1061:9aca452fe12a
if client closes a connection prematurely, then epoll (at least
in Linux 2.6.18) sends EPOLLERR|EPOLLHUP|EPOLLIN only and writer
does not know about the error
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 19 Jan 2007 08:10:06 +0000 |
parents | bff1312b84ed |
children | 9de12c8d8943 |
comparison
equal
deleted
inserted
replaced
1060:8e5c032e7855 | 1061:9aca452fe12a |
---|---|
1763 | 1763 |
1764 | 1764 |
1765 static void | 1765 static void |
1766 ngx_http_block_read(ngx_http_request_t *r) | 1766 ngx_http_block_read(ngx_http_request_t *r) |
1767 { | 1767 { |
1768 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1768 int n; |
1769 "http read blocked"); | 1769 char buf[1]; |
1770 ngx_err_t err; | |
1771 ngx_event_t *rev; | |
1772 ngx_connection_t *c; | |
1773 | |
1774 c = r->connection; | |
1775 rev = c->read; | |
1776 | |
1777 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http read blocked"); | |
1778 | |
1779 #if (NGX_HAVE_KQUEUE) | |
1780 | |
1781 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { | |
1782 | |
1783 if (!rev->pending_eof) { | |
1784 return; | |
1785 } | |
1786 | |
1787 rev->eof = 1; | |
1788 c->error = 1; | |
1789 err = rev->kq_errno; | |
1790 | |
1791 goto closed; | |
1792 } | |
1793 | |
1794 #endif | |
1795 | |
1796 n = recv(c->fd, buf, 1, MSG_PEEK); | |
1797 | |
1798 if (n == 0) { | |
1799 rev->eof = 1; | |
1800 c->error = 1; | |
1801 err = 0; | |
1802 | |
1803 goto closed; | |
1804 | |
1805 } else if (n == -1) { | |
1806 err = ngx_socket_errno; | |
1807 | |
1808 if (err != NGX_EAGAIN) { | |
1809 rev->eof = 1; | |
1810 c->error = 1; | |
1811 | |
1812 goto closed; | |
1813 } | |
1814 } | |
1770 | 1815 |
1771 /* aio does not call this handler */ | 1816 /* aio does not call this handler */ |
1772 | 1817 |
1773 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) | 1818 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && rev->active) { |
1774 && r->connection->read->active) | 1819 |
1775 { | 1820 if (ngx_del_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) { |
1776 if (ngx_del_event(r->connection->read, NGX_READ_EVENT, 0) | |
1777 == NGX_ERROR) | |
1778 { | |
1779 ngx_http_close_request(r, 0); | 1821 ngx_http_close_request(r, 0); |
1780 } | 1822 } |
1781 } | 1823 } |
1824 | |
1825 return; | |
1826 | |
1827 closed: | |
1828 | |
1829 if (err) { | |
1830 rev->error = 1; | |
1831 } | |
1832 | |
1833 ngx_log_error(NGX_LOG_INFO, c->log, err, | |
1834 "client closed prematurely connection"); | |
1835 | |
1836 ngx_http_close_request(r, 0); | |
1837 | |
1838 return; | |
1782 } | 1839 } |
1783 | 1840 |
1784 | 1841 |
1785 static void | 1842 static void |
1786 ngx_http_set_keepalive(ngx_http_request_t *r) | 1843 ngx_http_set_keepalive(ngx_http_request_t *r) |