diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-05-06 08:40:44 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-05-06 08:40:44 +0000 |
commit | c340a2841bb14ca2fae22892f61a9470b0584c59 (patch) | |
tree | 91fe08651eb25ea39c99cd7a129a4b57ec782edf /src | |
parent | ee4be0345fc2a62fcc0544ebed52523fdf2ffe40 (diff) | |
download | nginx-c340a2841bb14ca2fae22892f61a9470b0584c59.tar.gz nginx-c340a2841bb14ca2fae22892f61a9470b0584c59.zip |
delete level event of appropriate type, this should fix select()'s EBADF,
WSAENOTSOCK, and "select ready != events" alerts
Diffstat (limited to 'src')
-rw-r--r-- | src/http/ngx_http_upstream.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 4913fe38a..b21d01ab9 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -768,6 +768,7 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r, int n; char buf[1]; ngx_err_t err; + ngx_int_t event; ngx_connection_t *c; ngx_http_upstream_t *u; @@ -779,10 +780,22 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r, u = r->upstream; if (c->error) { + if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) { + + event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT; + + if (ngx_del_event(ev, event, 0) != NGX_OK) { + ngx_http_upstream_finalize_request(r, u, + NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } + } + if (!u->cacheable) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); } + return; } @@ -836,17 +849,15 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r, ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err, "http upstream recv(): %d", n); - /* - * we do not need to disable the write event because - * that event has NGX_USE_CLEAR_EVENT type - */ - if (ev->write && (n >= 0 || err == NGX_EAGAIN)) { return; } if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) { - if (ngx_del_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) { + + event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT; + + if (ngx_del_event(ev, event, 0) != NGX_OK) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_INTERNAL_SERVER_ERROR); return; |