From 46cd7c2a9bc740a2d3de03410dd84412b9d85856 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Fri, 2 Jul 2004 05:47:00 +0000 Subject: nginx-0.0.7-2004-07-02-09:47:00 import --- src/http/ngx_http_request.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/http/ngx_http_request.c') diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index fe1eaabcc..0063ee2bc 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1739,16 +1739,31 @@ void ngx_http_close_connection(ngx_connection_t *c) } } - fd = c->fd; + /* + * we have to clean the connection information before the closing + * because another thread may reopen the same file descriptor + * before we clean the connection + */ + fd = c->fd; c->fd = (ngx_socket_t) -1; c->data = NULL; ngx_destroy_pool(c->pool); - /* - * we has to clean the connection before the closing because another thread - * may reopen the same file descriptor before we clean the connection - */ +#if (NGX_THREADS) + + if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) { + ngx_unlock(&c->lock); + c->read->locked = 0; + c->write->locked = 0; + + ngx_mutex_unlock(ngx_posted_events_mutex); + } + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, + "connection lock: %d " PTR_FMT, c->lock, &c->lock); + +#endif if (ngx_close_socket(fd) == -1) { -- cgit