diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-10-30 11:51:06 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-30 11:51:06 +0300 |
commit | 68ee8f144242965c9650ad99604d1717c0f84c18 (patch) | |
tree | 7327fe5fcc7b45d0ade16767c74e918b8ba6f328 /src/os/unix/ngx_aio_read.c | |
parent | 14be46ee9862352fc055da8005e9bdf3dd1bc16e (diff) |
nginx-0.0.1-2003-10-30-11:51:06 import
Diffstat (limited to 'src/os/unix/ngx_aio_read.c')
-rw-r--r-- | src/os/unix/ngx_aio_read.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/os/unix/ngx_aio_read.c b/src/os/unix/ngx_aio_read.c index cb498eb5d..28deac6d2 100644 --- a/src/os/unix/ngx_aio_read.c +++ b/src/os/unix/ngx_aio_read.c @@ -24,12 +24,15 @@ ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size) rev = c->read; - if (rev->active) { + if (!rev->ready) { ngx_log_error(NGX_LOG_ALERT, rev->log, 0, "SECOND AIO POST"); return NGX_AGAIN; } - if (!rev->aio_complete) { + ngx_log_debug(rev->log, "rev->complete: %d" _ rev->complete); + ngx_log_debug(rev->log, "aio size: %d" _ size); + + if (!rev->complete) { ngx_memzero(&rev->aiocb, sizeof(struct aiocb)); rev->aiocb.aio_fildes = c->fd; @@ -49,12 +52,13 @@ ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size) return NGX_ERROR; } - ngx_log_debug(rev->log, "aio_read: OK"); + ngx_log_debug(rev->log, "aio_read: #%d OK" _ c->fd); rev->active = 1; + rev->ready = 0; } - rev->aio_complete = 0; + rev->complete = 0; n = aio_error(&rev->aiocb); if (n == -1) { @@ -65,15 +69,17 @@ ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size) if (n != 0) { if (n == NGX_EINPROGRESS) { - if (!rev->active) { + if (rev->ready) { ngx_log_error(NGX_LOG_ALERT, rev->log, n, "aio_read() still in progress"); + rev->ready = 0; } return NGX_AGAIN; } ngx_log_error(NGX_LOG_CRIT, rev->log, n, "aio_read() failed"); rev->error = 1; + rev->ready = 0; return NGX_ERROR; } @@ -83,16 +89,20 @@ ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size) "aio_return() failed"); rev->error = 1; + rev->ready = 0; return NGX_ERROR; } - rev->active = 0; - - ngx_log_debug(rev->log, "aio_read: %d" _ n); + ngx_log_debug(rev->log, "aio_read: #%d %d" _ c->fd _ n); if (n == 0) { rev->eof = 1; + rev->ready = 0; + } else { + rev->ready = 1; } + rev->active = 0; + return n; } |