diff src/http/ngx_http_request.c @ 375:744ccb59062d

nginx-0.0.7-2004-07-02-19:54:34 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 02 Jul 2004 15:54:34 +0000
parents 213f17e9f776
children 41437e4fd9b4
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1017,7 +1017,7 @@ void ngx_http_finalize_request(ngx_http_
         ngx_del_timer(r->connection->write);
     }
 
-    if (r->connection->read->kq_eof) {
+    if (r->connection->read->pending_eof) {
 #if (NGX_KQUEUE)
         ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log,
                        r->connection->read->kq_errno,
@@ -1730,11 +1730,11 @@ void ngx_http_close_connection(ngx_conne
         ngx_del_conn(c, NGX_CLOSE_EVENT);
 
     } else {
-        if (c->read->active || c->read->posted || c->read->disabled) {
+        if (c->read->active || c->read->disabled) {
             ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
         }
 
-        if (c->write->active || c->write->posted || c->write->disabled) {
+        if (c->write->active || c->write->disabled) {
             ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
         }
     }
@@ -1745,26 +1745,49 @@ void ngx_http_close_connection(ngx_conne
      * before we clean the connection
      */
 
-    fd = c->fd;
-    c->fd = (ngx_socket_t) -1;
-    c->data = NULL;
-    ngx_destroy_pool(c->pool);
-
 #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;
 
+        c->read->closed = 1;
+        c->write->closed = 1;
+
+        if (c->read->prev) {
+            ngx_delete_posted_event(c->read);
+        }
+
+        if (c->write->prev) {
+            ngx_delete_posted_event(c->write);
+        }
+
         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);
+#else
+
+    c->read->closed = 1;
+    c->write->closed = 1;
+
+    if (c->read->prev) {
+        ngx_delete_posted_event(c->read);
+    }
+
+    if (c->write->prev) {
+        ngx_delete_posted_event(c->write);
+    }
 
 #endif
 
+    fd = c->fd;
+    c->fd = (ngx_socket_t) -1;
+    c->data = NULL;
+
+    ngx_destroy_pool(c->pool);
+
     if (ngx_close_socket(fd) == -1) {
 
         /* we use ngx_cycle->log because c->log was in c->pool */