nginx-0.0.3-2004-04-12-20:38:09 import
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index abc577b..6564e9a 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -263,6 +263,7 @@
      */
 
     if (flags & NGX_CLOSE_EVENT) {
+        ev->posted = 0;
         return NGX_OK;
     }
 
@@ -464,10 +465,6 @@
             ev = (ngx_event_t *) ((uintptr_t) ev & (uintptr_t) ~1);
             ev->returned_instance = instance;
 
-            if (ev->log && (ev->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
-                ngx_kqueue_dump_event(ev->log, &event_list[i]);
-            }
-
             if (!ev->active || ev->instance != instance) {
 
                 /*
@@ -480,6 +477,10 @@
                 continue;
             }
 
+            if (ev->log && (ev->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
+                ngx_kqueue_dump_event(ev->log, &event_list[i]);
+            }
+
             ev->available = event_list[i].data;
 
             if (event_list[i].flags & EV_EOF) {