aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_aio_read.c109
-rw-r--r--src/os/unix/ngx_aio_read_chain.c78
-rw-r--r--src/os/unix/ngx_aio_write.c109
-rw-r--r--src/os/unix/ngx_aio_write_chain.c100
-rw-r--r--src/os/unix/ngx_freebsd_config.h2
-rw-r--r--src/os/unix/ngx_os.h8
6 files changed, 1 insertions, 405 deletions
diff --git a/src/os/unix/ngx_aio_read.c b/src/os/unix/ngx_aio_read.c
deleted file mode 100644
index 784988173..000000000
--- a/src/os/unix/ngx_aio_read.c
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) Nginx, Inc.
- */
-
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-#include <ngx_event.h>
-
-
-extern int ngx_kqueue;
-
-
-ssize_t
-ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size)
-{
- int n;
- ngx_event_t *rev;
-
- rev = c->read;
-
- if (!rev->ready) {
- ngx_log_error(NGX_LOG_ALERT, c->log, 0, "second aio post");
- return NGX_AGAIN;
- }
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "rev->complete: %d", rev->complete);
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "aio size: %d", size);
-
- if (!rev->complete) {
- ngx_memzero(&rev->aiocb, sizeof(struct aiocb));
-
- rev->aiocb.aio_fildes = c->fd;
- rev->aiocb.aio_buf = buf;
- rev->aiocb.aio_nbytes = size;
-
-#if (NGX_HAVE_KQUEUE)
- rev->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue;
- rev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
- rev->aiocb.aio_sigevent.sigev_value.sigval_ptr = rev;
-#endif
-
- if (aio_read(&rev->aiocb) == -1) {
- ngx_log_error(NGX_LOG_CRIT, rev->log, ngx_errno,
- "aio_read() failed");
- rev->error = 1;
- return NGX_ERROR;
- }
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "aio_read: #%d OK", c->fd);
-
- rev->active = 1;
- rev->ready = 0;
- }
-
- rev->complete = 0;
-
- n = aio_error(&rev->aiocb);
- if (n == -1) {
- ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, "aio_error() failed");
- rev->error = 1;
- return NGX_ERROR;
- }
-
- if (n != 0) {
- if (n == NGX_EINPROGRESS) {
- if (rev->ready) {
- ngx_log_error(NGX_LOG_ALERT, c->log, n,
- "aio_read() still in progress");
- rev->ready = 0;
- }
- return NGX_AGAIN;
- }
-
- ngx_log_error(NGX_LOG_CRIT, c->log, n, "aio_read() failed");
- rev->error = 1;
- rev->ready = 0;
- return NGX_ERROR;
- }
-
- n = aio_return(&rev->aiocb);
- if (n == -1) {
- ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
- "aio_return() failed");
-
- rev->error = 1;
- rev->ready = 0;
- return NGX_ERROR;
- }
-
- ngx_log_debug2(NGX_LOG_DEBUG_EVENT, rev->log, 0,
- "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;
-}
diff --git a/src/os/unix/ngx_aio_read_chain.c b/src/os/unix/ngx_aio_read_chain.c
deleted file mode 100644
index d8722b2c1..000000000
--- a/src/os/unix/ngx_aio_read_chain.c
+++ /dev/null
@@ -1,78 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) Nginx, Inc.
- */
-
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-#include <ngx_event.h>
-
-
-ssize_t
-ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit)
-{
- int n;
- u_char *buf, *prev;
- size_t size;
- ssize_t total;
-
- if (c->read->pending_eof) {
- c->read->ready = 0;
- return 0;
- }
-
- total = 0;
-
- while (cl) {
-
- /* we can post the single aio operation only */
-
- if (!c->read->ready) {
- return total ? total : NGX_AGAIN;
- }
-
- buf = cl->buf->last;
- prev = cl->buf->last;
- size = 0;
-
- /* coalesce the neighbouring bufs */
-
- while (cl && prev == cl->buf->last) {
- size += cl->buf->end - cl->buf->last;
- prev = cl->buf->end;
- cl = cl->next;
- }
-
- n = ngx_aio_read(c, buf, size);
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_read: %d", n);
-
- if (n == NGX_AGAIN) {
- return total ? total : NGX_AGAIN;
- }
-
- if (n == NGX_ERROR) {
- return NGX_ERROR;
- }
-
- if (n == 0) {
- c->read->pending_eof = 1;
- if (total) {
- c->read->eof = 0;
- c->read->ready = 1;
- }
- return total;
- }
-
- if (n > 0) {
- total += n;
- }
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "aio_read total: %d", total);
- }
-
- return total ? total : NGX_AGAIN;
-}
diff --git a/src/os/unix/ngx_aio_write.c b/src/os/unix/ngx_aio_write.c
deleted file mode 100644
index f0d93918e..000000000
--- a/src/os/unix/ngx_aio_write.c
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) Nginx, Inc.
- */
-
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-#include <ngx_event.h>
-
-
-extern int ngx_kqueue;
-
-
-ssize_t
-ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size)
-{
- int n;
- ngx_event_t *wev;
-
- wev = c->write;
-
- if (!wev->ready) {
- return NGX_AGAIN;
- }
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, wev->log, 0,
- "aio: wev->complete: %d", wev->complete);
-
- if (!wev->complete) {
- ngx_memzero(&wev->aiocb, sizeof(struct aiocb));
-
- wev->aiocb.aio_fildes = c->fd;
- wev->aiocb.aio_buf = buf;
- wev->aiocb.aio_nbytes = size;
-
-#if (NGX_HAVE_KQUEUE)
- wev->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue;
- wev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
- wev->aiocb.aio_sigevent.sigev_value.sigval_ptr = wev;
-#endif
-
- if (aio_write(&wev->aiocb) == -1) {
- ngx_log_error(NGX_LOG_CRIT, wev->log, ngx_errno,
- "aio_write() failed");
- return NGX_ERROR;
- }
-
- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, wev->log, 0, "aio_write: OK");
-
- wev->active = 1;
- wev->ready = 0;
- }
-
- wev->complete = 0;
-
- n = aio_error(&wev->aiocb);
- if (n == -1) {
- ngx_log_error(NGX_LOG_CRIT, wev->log, ngx_errno, "aio_error() failed");
- wev->error = 1;
- return NGX_ERROR;
- }
-
- if (n != 0) {
- if (n == NGX_EINPROGRESS) {
- if (wev->ready) {
- ngx_log_error(NGX_LOG_ALERT, wev->log, n,
- "aio_write() still in progress");
- wev->ready = 0;
- }
- return NGX_AGAIN;
- }
-
- ngx_log_error(NGX_LOG_CRIT, wev->log, n, "aio_write() failed");
- wev->error = 1;
- wev->ready = 0;
-
-#if 1
- n = aio_return(&wev->aiocb);
- if (n == -1) {
- ngx_log_error(NGX_LOG_ALERT, wev->log, ngx_errno,
- "aio_return() failed");
- }
-
- ngx_log_error(NGX_LOG_CRIT, wev->log, n, "aio_return() %d", n);
-#endif
-
- return NGX_ERROR;
- }
-
- n = aio_return(&wev->aiocb);
- if (n == -1) {
- ngx_log_error(NGX_LOG_ALERT, wev->log, ngx_errno,
- "aio_return() failed");
-
- wev->error = 1;
- wev->ready = 0;
- return NGX_ERROR;
- }
-
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, wev->log, 0, "aio_write: %d", n);
-
- wev->active = 0;
- wev->ready = 1;
-
- return n;
-}
diff --git a/src/os/unix/ngx_aio_write_chain.c b/src/os/unix/ngx_aio_write_chain.c
deleted file mode 100644
index b0c25085d..000000000
--- a/src/os/unix/ngx_aio_write_chain.c
+++ /dev/null
@@ -1,100 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) Nginx, Inc.
- */
-
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-#include <ngx_event.h>
-
-
-ngx_chain_t *
-ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
-{
- u_char *buf, *prev;
- off_t send, sent;
- size_t len;
- ssize_t n, size;
- ngx_chain_t *cl;
-
- /* the maximum limit size is the maximum size_t value - the page size */
-
- if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) {
- limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;
- }
-
- send = 0;
- sent = 0;
- cl = in;
-
- while (cl) {
-
- if (cl->buf->pos == cl->buf->last) {
- cl = cl->next;
- continue;
- }
-
- /* we can post the single aio operation only */
-
- if (!c->write->ready) {
- return cl;
- }
-
- buf = cl->buf->pos;
- prev = buf;
- len = 0;
-
- /* coalesce the neighbouring bufs */
-
- while (cl && prev == cl->buf->pos && send < limit) {
- if (ngx_buf_special(cl->buf)) {
- continue;
- }
-
- size = cl->buf->last - cl->buf->pos;
-
- if (send + size > limit) {
- size = limit - send;
- }
-
- len += size;
- prev = cl->buf->pos + size;
- send += size;
- cl = cl->next;
- }
-
- n = ngx_aio_write(c, buf, len);
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_write: %z", n);
-
- if (n == NGX_ERROR) {
- return NGX_CHAIN_ERROR;
- }
-
- if (n > 0) {
- sent += n;
- c->sent += n;
- }
-
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "aio_write sent: %O", c->sent);
-
- for (cl = in; cl; cl = cl->next) {
-
- if (sent >= cl->buf->last - cl->buf->pos) {
- sent -= cl->buf->last - cl->buf->pos;
- cl->buf->pos = cl->buf->last;
-
- continue;
- }
-
- cl->buf->pos += sent;
-
- break;
- }
- }
-
- return cl;
-}
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 8f060514d..9a2578875 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -86,7 +86,7 @@
#endif
-#if (NGX_HAVE_FILE_AIO || NGX_HAVE_AIO)
+#if (NGX_HAVE_FILE_AIO)
#include <aio.h>
typedef struct aiocb ngx_aiocb_t;
#endif
diff --git a/src/os/unix/ngx_os.h b/src/os/unix/ngx_os.h
index 09f79175e..d8bcb0140 100644
--- a/src/os/unix/ngx_os.h
+++ b/src/os/unix/ngx_os.h
@@ -48,14 +48,6 @@ ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
off_t limit);
-#if (NGX_HAVE_AIO)
-ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size);
-ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit);
-ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size);
-ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
- off_t limit);
-#endif
-
#if (IOV_MAX > 64)
#define NGX_IOVS_PREALLOCATE 64