diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2003-10-12 16:49:16 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-12 16:49:16 +0000 |
| commit | 0a280a3fc081877bc45cbdc0511a8cc42675213c (patch) | |
| tree | b5ea17e3be5eab555cf40f6304338a88bd641527 /src/os | |
| parent | b3e73d869ecef9248468e0ccc2d7d0abdbee495c (diff) | |
| download | nginx-0a280a3fc081877bc45cbdc0511a8cc42675213c.tar.gz nginx-0a280a3fc081877bc45cbdc0511a8cc42675213c.tar.bz2 | |
nginx-0.0.1-2003-10-12-20:49:16 import
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/unix/ngx_aio_write.c | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_aio_write_chain.c | 39 | ||||
| -rw-r--r-- | src/os/unix/ngx_freebsd_init.c | 5 | ||||
| -rw-r--r-- | src/os/unix/ngx_freebsd_sendfile_chain.c | 4 | ||||
| -rw-r--r-- | src/os/unix/ngx_recv.c | 5 | ||||
| -rw-r--r-- | src/os/unix/ngx_writev_chain.c | 5 | ||||
| -rw-r--r-- | src/os/win32/ngx_win32_config.h | 4 | ||||
| -rw-r--r-- | src/os/win32/ngx_wsarecv.c | 8 | ||||
| -rw-r--r-- | src/os/win32/ngx_wsasend_chain.c | 10 |
9 files changed, 55 insertions, 26 deletions
diff --git a/src/os/unix/ngx_aio_write.c b/src/os/unix/ngx_aio_write.c index 3a4d8e0b4..5eded37b7 100644 --- a/src/os/unix/ngx_aio_write.c +++ b/src/os/unix/ngx_aio_write.c @@ -109,6 +109,7 @@ ngx_log_debug(ev->log, "aio: aiocb: %08x" _ &ev->aiocb); return NGX_ERROR; } + ev->active = 0; ngx_log_debug(ev->log, "aio_write: %d" _ rc); return rc; diff --git a/src/os/unix/ngx_aio_write_chain.c b/src/os/unix/ngx_aio_write_chain.c index b12afec41..b8760b0fa 100644 --- a/src/os/unix/ngx_aio_write_chain.c +++ b/src/os/unix/ngx_aio_write_chain.c @@ -1,6 +1,7 @@ #include <ngx_config.h> #include <ngx_core.h> +#include <ngx_event.h> #include <ngx_aio.h> @@ -17,10 +18,18 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in) ce = in; while (ce) { + + /* we can post the single aio operation only */ + + if (c->write->active) { + return ce; + } + buf = prev = ce->hunk->pos; size = 0; /* coalesce the neighbouring chain entries */ + while (ce && prev == ce->hunk->pos) { size += ce->hunk->last - ce->hunk->pos; prev = ce->hunk->last; @@ -33,34 +42,32 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in) ngx_log_debug(c->log, "aio_write rc: %d" _ rc); #endif + if (rc == NGX_ERROR) { + return NGX_CHAIN_ERROR; + } + if (rc > 0) { sent += rc; c->sent += rc; - - } else if (rc == NGX_ERROR) { - return NGX_CHAIN_ERROR; - - } else if (rc == NGX_AGAIN) { - break; } - } #if (NGX_DEBUG_WRITE_CHAIN) - ngx_log_debug(c->log, "aio_write sent: " OFF_FMT _ c->sent); + ngx_log_debug(c->log, "aio_write sent: " OFF_FMT _ c->sent); #endif - for (ce = in; ce; ce = ce->next) { + for (ce = in; ce; ce = ce->next) { - if (sent >= ce->hunk->last - ce->hunk->pos) { - sent -= ce->hunk->last - ce->hunk->pos; - ce->hunk->pos = ce->hunk->last; + if (sent >= ce->hunk->last - ce->hunk->pos) { + sent -= ce->hunk->last - ce->hunk->pos; + ce->hunk->pos = ce->hunk->last; - continue; - } + continue; + } - ce->hunk->pos += sent; + ce->hunk->pos += sent; - break; + break; + } } return ce; diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c index 1a3077114..058711681 100644 --- a/src/os/unix/ngx_freebsd_init.c +++ b/src/os/unix/ngx_freebsd_init.c @@ -19,8 +19,13 @@ ngx_os_io_t ngx_os_io = { ngx_unix_recv, ngx_readv_chain, NULL, +#if (HAVE_FREEBSD_SENDFILE) ngx_freebsd_sendfile_chain, NGX_HAVE_SENDFILE|NGX_HAVE_ZEROCOPY +#else + ngx_writev_chain, + NULL +#endif }; diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c index 5db40808c..f7751a772 100644 --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -34,6 +34,10 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) ngx_hunk_t *file; ngx_chain_t *ce, *tail; + if (!c->write->ready) { + return in; + } + do { ce = in; file = NULL; diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c index 154565413..cef432821 100644 --- a/src/os/unix/ngx_recv.c +++ b/src/os/unix/ngx_recv.c @@ -43,8 +43,11 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size) if (n >= 0) { if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { rev->available -= n; - if (rev->available == 0) { + if (rev->available <= 0) { rev->ready = 0; + if (rev->available < 0) { + rev->available = 0; + } } return n; diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c index 32b2dd48d..70141e341 100644 --- a/src/os/unix/ngx_writev_chain.c +++ b/src/os/unix/ngx_writev_chain.c @@ -1,6 +1,7 @@ #include <ngx_config.h> #include <ngx_core.h> +#include <ngx_event.h> ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in) @@ -13,6 +14,10 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in) ngx_array_t iovecs; ngx_chain_t *ce; + if (!c->write->ready) { + return in; + } + ngx_init_array(iovecs, c->pool, 10, sizeof(struct iovec), NGX_CHAIN_ERROR); prev = NULL; diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h index 96cf000ee..7d123d71c 100644 --- a/src/os/win32/ngx_win32_config.h +++ b/src/os/win32/ngx_win32_config.h @@ -36,4 +36,8 @@ #endif +/* STUB */ +#define HAVE_LITTLE_ENDIAN 1 + + #endif /* _NGX_WIN32_CONFIG_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_wsarecv.c b/src/os/win32/ngx_wsarecv.c index 038554a68..883bed805 100644 --- a/src/os/win32/ngx_wsarecv.c +++ b/src/os/win32/ngx_wsarecv.c @@ -17,12 +17,12 @@ ssize_t ngx_wsarecv(ngx_connection_t *c, char *buf, size_t size) rev = c->read; bytes = 0; - if ((ngx_event_flags & NGX_HAVE_AIO_EVENT) && rev->ready) { + if ((ngx_event_flags & NGX_USE_AIO_EVENT) && rev->ready) { rev->ready = 0; /* the overlapped WSARecv() completed */ - if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) { + if (ngx_event_flags & NGX_USE_IOCP_EVENT) { if (rev->ovlp.error) { ngx_log_error(NGX_LOG_ERR, c->log, rev->ovlp.error, "WSARecv() failed"); @@ -44,7 +44,7 @@ ssize_t ngx_wsarecv(ngx_connection_t *c, char *buf, size_t size) return bytes; } - if (ngx_event_flags & NGX_HAVE_AIO_EVENT) { + if (ngx_event_flags & NGX_USE_AIO_EVENT) { ovlp = (LPWSAOVERLAPPED) &c->read->ovlp; ngx_memzero(ovlp, sizeof(WSAOVERLAPPED)); @@ -75,7 +75,7 @@ ssize_t ngx_wsarecv(ngx_connection_t *c, char *buf, size_t size) } } - if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) { + if (ngx_event_flags & NGX_USE_IOCP_EVENT) { /* * If a socket was bound with I/O completion port diff --git a/src/os/win32/ngx_wsasend_chain.c b/src/os/win32/ngx_wsasend_chain.c index ebaa77e96..5bfd71542 100644 --- a/src/os/win32/ngx_wsasend_chain.c +++ b/src/os/win32/ngx_wsasend_chain.c @@ -65,8 +65,8 @@ non-block wev = c->write; - if (((ngx_event_flags & NGX_HAVE_AIO_EVENT) && !wev->ready) - || ((ngx_event_flags & NGX_HAVE_AIO_EVENT) == 0)) + if (((ngx_event_flags & NGX_USE_AIO_EVENT) && !wev->ready) + || ((ngx_event_flags & NGX_USE_AIO_EVENT) == 0)) { /* * WSABUFs must be 4-byte aligned otherwise @@ -94,7 +94,7 @@ non-block } } - if (ngx_event_flags & NGX_HAVE_AIO_EVENT) { + if (ngx_event_flags & NGX_USE_AIO_EVENT) { ovlp = (LPWSAOVERLAPPED) &c->write->ovlp; ngx_memzero(ovlp, sizeof(WSAOVERLAPPED)); @@ -120,7 +120,7 @@ non-block } else { - if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) { + if (ngx_event_flags & NGX_USE_IOCP_EVENT) { /* * If a socket was bound with I/O completion port then @@ -133,7 +133,7 @@ non-block } } else { - if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) { + if (ngx_event_flags & NGX_USE_IOCP_EVENT) { wev->ready = 0; /* the overlapped WSASend() completed */ |
