diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-07-05 19:08:23 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-07-05 19:08:23 +0400 |
commit | f1be53b48a52a79bc9edee07b4a3d0169339f05b (patch) | |
tree | 0e63eaea1550dd534fab81589049bd20c9cf826f /src/http/modules/proxy | |
parent | 32fcd5cf64b9f55f9184e98e39f1b2152321a710 (diff) |
nginx-0.0.7-2004-07-05-19:08:23 import
Diffstat (limited to 'src/http/modules/proxy')
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 31 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 3 |
2 files changed, 31 insertions, 3 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 5d646bb1c..5479717b9 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -608,6 +608,7 @@ void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc) void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p) { + ngx_socket_t fd; ngx_connection_t *c; c = p->upstream->peer.connection; @@ -650,12 +651,36 @@ void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p) } } - if (ngx_close_socket(c->fd) == -1) { - ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno, - ngx_close_socket_n " failed"); + /* + * we have to clean the connection information before the closing + * because another thread may reopen the same file descriptor + * before we clean the connection + */ + + if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) { + + if (c->read->prev) { + ngx_delete_posted_event(c->read); + } + + if (c->write->prev) { + ngx_delete_posted_event(c->write); + } + + c->read->closed = 1; + c->write->closed = 1; + + ngx_mutex_unlock(ngx_posted_events_mutex); } + fd = c->fd; c->fd = (ngx_socket_t) -1; + c->data = NULL; + + if (ngx_close_socket(fd) == -1) { + ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno, + ngx_close_socket_n " failed"); + } } diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index 9ed4d7f61..335d1dacd 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -62,6 +62,9 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p) u->peer.log_error = NGX_ERROR_ERR; u->peer.peers = p->lcf->peers; u->peer.tries = p->lcf->peers->number; +#if (NGX_THREADS) + u->peer.lock = &r->connection->lock; +#endif u->method = r->method; |