diff src/event/modules/ngx_aio_module.c @ 95:b48066122884

nginx-0.0.1-2003-05-23-15:53:01 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 23 May 2003 11:53:01 +0000
parents 8220378432a8
children a23d010f356d
line wrap: on
line diff
--- a/src/event/modules/ngx_aio_module.c
+++ b/src/event/modules/ngx_aio_module.c
@@ -81,7 +81,7 @@ static void ngx_aio_done(ngx_log_t *log)
 }
 
 
-/* The event adding and deleteing are needed for the listening sockets */
+/* The event adding and deleting are needed for the listening sockets */
 
 static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags)
 {
@@ -99,49 +99,38 @@ static int ngx_aio_del_connection(ngx_co
 {
     int  rc;
 
-    if (c->read->active || c->write->active) {
-        rc = aio_cancel(c->fd, NULL);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_cancel() failed");
-            return NGX_ERROR;
-        }
+    if (c->read->active == 0 && c->write->active == 0) {
+        return NGX_OK;
+    }
 
-        ngx_log_debug(c->log, "aio_cancel: %d" _ rc);
+    rc = aio_cancel(c->fd, NULL);
 
-#if 0
-        rc = aio_error(&c->read->aiocb);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_error() failed");
-            return NGX_ERROR;
-        }
+    ngx_log_debug(c->log, "aio_cancel: %d" _ rc);
 
-        ngx_log_debug(c->log, "aio_error: %d" _ rc);
-#endif
+    if (rc == AIO_CANCELED) {
+        c->read->active = c->write->active = 0;
+        return NGX_OK;
     }
 
-#if 0
-    if (c->write->active) {
-        rc = aio_cancel(c->fd, &c->write->aiocb);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_cancel() failed");
-            return NGX_ERROR;
-        }
-
-        ngx_log_debug(c->log, "aio_cancel: %d" _ rc);
+    if (rc == AIO_ALLDONE) {
+        c->read->active = c->write->active = 0;
+        ngx_log_error(NGX_LOG_ALERT, c->log, 0,
+                      "aio_cancel() returned AIO_ALLDONE");
+        return NGX_OK;
+    }
 
-        rc = aio_error(&c->read->aiocb);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_error() failed");
-            return NGX_ERROR;
-        }
+    if (rc == -1) {
+        ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
+                      "aio_cancel() failed");
+        return NGX_ERROR;
+    }
 
-        ngx_log_debug(c->log, "aio_error: %d" _ rc);
+    if (rc == AIO_NOTCANCELED) {
+        ngx_log_error(NGX_LOG_ALERT, c->log, 0,
+                      "aio_cancel() returned AIO_NOTCANCELED");
+
+        return NGX_ERROR;
     }
-#endif
 
     return NGX_OK;
 }
@@ -152,7 +141,7 @@ static int ngx_aio_process_events(ngx_lo
     return ngx_kqueue_module_ctx.actions.process(log);
 }
 
-#endif
+#endif /* HAVE_KQUEUE */
 
 
 #if 0