diff options
Diffstat (limited to 'src/event/modules/ngx_aio_module.c')
-rw-r--r-- | src/event/modules/ngx_aio_module.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/event/modules/ngx_aio_module.c b/src/event/modules/ngx_aio_module.c index 24d049f80..a5375e917 100644 --- a/src/event/modules/ngx_aio_module.c +++ b/src/event/modules/ngx_aio_module.c @@ -13,6 +13,7 @@ static int ngx_aio_init(ngx_log_t *log); static void ngx_aio_done(ngx_log_t *log); static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags); static int ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags); +static int ngx_aio_del_connection(ngx_connection_t *c); static int ngx_aio_process_events(ngx_log_t *log); @@ -39,7 +40,7 @@ ngx_event_module_t ngx_aio_module_ctx = { NULL, /* enable an event */ NULL, /* disable an event */ NULL, /* add an connection */ - NULL, /* delete an connection */ + ngx_aio_del_connection, /* delete an connection */ ngx_aio_process_events, /* process the events */ ngx_aio_init, /* init the events */ ngx_aio_done /* done the events */ @@ -94,6 +95,58 @@ static int ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags) } +static int ngx_aio_del_connection(ngx_connection_t *c) +{ + 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; + } + + ngx_log_debug(c->log, "aio_cancel: %d" _ rc); + +#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_error: %d" _ rc); +#endif + } + +#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); + + 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_error: %d" _ rc); + } +#endif + + return NGX_OK; +} + + static int ngx_aio_process_events(ngx_log_t *log) { return ngx_kqueue_module_ctx.actions.process(log); |