nginx-0.0.1-2003-10-12-20:49:16 import
diff --git a/src/os/unix/ngx_aio_write.c b/src/os/unix/ngx_aio_write.c
index 3a4d8e0..5eded37 100644
--- a/src/os/unix/ngx_aio_write.c
+++ b/src/os/unix/ngx_aio_write.c
@@ -109,6 +109,7 @@
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 b12afec..b8760b0 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 @@
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_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;
+
+ break;
}
-
- ce->hunk->pos += sent;
-
- break;
}
return ce;
diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c
index 1a30771..0587116 100644
--- a/src/os/unix/ngx_freebsd_init.c
+++ b/src/os/unix/ngx_freebsd_init.c
@@ -19,8 +19,13 @@
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 5db4080..f7751a7 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -34,6 +34,10 @@
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 1545654..cef4328 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -43,8 +43,11 @@
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 32b2dd4..70141e3 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_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 96cf000..7d123d7 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 038554a..883bed8 100644
--- a/src/os/win32/ngx_wsarecv.c
+++ b/src/os/win32/ngx_wsarecv.c
@@ -17,12 +17,12 @@
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 @@
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 @@
}
}
- 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 ebaa77e..5bfd715 100644
--- a/src/os/win32/ngx_wsasend_chain.c
+++ b/src/os/win32/ngx_wsasend_chain.c
@@ -65,8 +65,8 @@
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 @@
}
}
- 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 @@
} 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 @@
}
} else {
- if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) {
+ if (ngx_event_flags & NGX_USE_IOCP_EVENT) {
wev->ready = 0;
/* the overlapped WSASend() completed */