diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-04-02 15:13:20 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-04-02 15:13:20 +0000 |
commit | c972a3fe2774c329cd64fdaf36f51e28a130bf4c (patch) | |
tree | d510db8b672c1d8eddc2a533d166f04223b4de81 /src/http/modules | |
parent | debb39eaedf46e63d22f4604da01cf26a1e8a930 (diff) | |
download | nginx-c972a3fe2774c329cd64fdaf36f51e28a130bf4c.tar.gz nginx-c972a3fe2774c329cd64fdaf36f51e28a130bf4c.zip |
nginx-0.0.3-2004-04-02-19:13:20 import
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 95d565442..cb29559ee 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -381,6 +381,9 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev) p = ngx_http_get_module_ctx(r, ngx_http_proxy_module); #if (HAVE_KQUEUE) + + /* TODO: KEVENT_EVENT */ + if (ev->kq_eof) { ev->eof = 1; @@ -405,6 +408,44 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev) ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); } } + +#else + + n = recv(c->fd, buf, 1, MSG_PEEK); + + if (n > 0) { + /* TODO: delete level */ + return; + } + + if (n == -1) { + err = ngx_socket_errno; + if (err == NGX_EAGAIN) { + return; + } + + ev->error = 1; + + } else if (n == 0) { + err = 0; + ev->eof = 1; + } + + if (!p->cachable && p->upstream->peer.connection) { + ngx_log_error(NGX_LOG_INFO, ev->log, err, + "client have closed prematurely connection, " + "so upstream connection is closed too"); + ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); + return; + } + + ngx_log_error(NGX_LOG_INFO, ev->log, ev->err, + "client have closed prematurely connection"); + + if (p->upstream == NULL || p->upstream->peer.connection == NULL) { + ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); + } + #endif } |