Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-09-16 20:10:13 +0400
committerIgor Sysoev <igor@sysoev.ru>2004-09-16 20:10:13 +0400
commit95d00c435ace44f782bbb70dd5eac7fb1f9b8610 (patch)
tree53799251b1b9c7d27eb1a63e5020daa5c2baba4e /src/os/unix
parent85cccfba8d0c33e7f3546e630f67c1a1940c8d1f (diff)
nginx-0.0.11-2004-09-16-20:10:13 import
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_atomic.h2
-rw-r--r--src/os/unix/ngx_freebsd_sendfile_chain.c39
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c18
-rw-r--r--src/os/unix/ngx_solaris_sendfilev_chain.c23
4 files changed, 61 insertions, 21 deletions
diff --git a/src/os/unix/ngx_atomic.h b/src/os/unix/ngx_atomic.h
index 552edd5e8..41c670475 100644
--- a/src/os/unix/ngx_atomic.h
+++ b/src/os/unix/ngx_atomic.h
@@ -108,7 +108,7 @@ static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
ngx_atomic_t old,
ngx_atomic_t set)
{
- uint32_t res = (u_int32_t) set;
+ uint32_t res = (uint32_t) set;
__asm__ volatile (
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 5227a21bd..5a8164f4f 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -12,14 +12,14 @@
/*
* Although FreeBSD sendfile() allows to pass a header and a trailer
* it can not send a header with a part of the file in one packet until
- * FreeBSD 5.2-STABLE. Besides over the fast ethernet connection sendfile()
+ * FreeBSD 5.3. Besides over the fast ethernet connection sendfile()
* may send the partially filled packets, i.e. the 8 file pages may be sent
* as the 11 full 1460-bytes packets, then one incomplete 324-bytes packet,
* and then again the 11 full 1460-bytes packets.
*
* So we use the TCP_NOPUSH option (similar to Linux's TCP_CORK)
* to postpone the sending - it not only sends a header and the first part
- * of the file in one packet but also sends file pages in the full packets.
+ * of the file in one packet but also sends the file pages in the full packets.
*
* But until FreeBSD 4.5 the turning TCP_NOPUSH off does not flush a pending
* data that less than MSS so that data may be sent with 5 second delay.
@@ -28,6 +28,10 @@
*/
+#define NGX_HEADERS 8
+#define NGX_TRAILERS 4
+
+
ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
off_t limit)
{
@@ -37,13 +41,13 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
size_t hsize, fsize;
ssize_t size;
ngx_uint_t eintr, eagain, complete;
- struct iovec *iov;
- struct sf_hdtr hdtr;
ngx_err_t err;
ngx_buf_t *file;
ngx_array_t header, trailer;
ngx_event_t *wev;
ngx_chain_t *cl;
+ struct sf_hdtr hdtr;
+ struct iovec *iov, headers[NGX_HEADERS], trailers[NGX_TRAILERS];
wev = c->write;
@@ -66,6 +70,16 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
send = 0;
eagain = 0;
+ header.elts = headers;
+ header.size = sizeof(struct iovec);
+ header.nalloc = NGX_HEADERS;
+ header.pool = c->pool;
+
+ trailer.elts = trailers;
+ trailer.size = sizeof(struct iovec);
+ trailer.nalloc = NGX_TRAILERS;
+ trailer.pool = c->pool;
+
for ( ;; ) {
file = NULL;
fsize = 0;
@@ -74,10 +88,8 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
complete = 0;
sprev = send;
- ngx_init_array(header, c->pool, 10, sizeof(struct iovec),
- NGX_CHAIN_ERROR);
- ngx_init_array(trailer, c->pool, 10, sizeof(struct iovec),
- NGX_CHAIN_ERROR);
+ header.nelts = 0;
+ trailer.nelts = 0;
/* create the header iovec and coalesce the neighbouring bufs */
@@ -106,7 +118,10 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
iov->iov_len += size;
} else {
- ngx_test_null(iov, ngx_push_array(&header), NGX_CHAIN_ERROR);
+ if (!(iov = ngx_array_push(&header))) {
+ return NGX_CHAIN_ERROR;
+ }
+
iov->iov_base = (void *) cl->buf->pos;
iov->iov_len = size;
}
@@ -177,8 +192,10 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
iov->iov_len += size;
} else {
- ngx_test_null(iov, ngx_push_array(&trailer),
- NGX_CHAIN_ERROR);
+ if (!(iov = ngx_array_push(&trailer))) {
+ return NGX_CHAIN_ERROR;
+ }
+
iov->iov_base = (void *) cl->buf->pos;
iov->iov_len = size;
}
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index 48c09dffa..3f8671266 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -19,6 +19,9 @@
*/
+#define NGX_HEADERS 8
+
+
ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
off_t limit)
{
@@ -28,12 +31,12 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
size_t fsize;
ssize_t size, sent;
ngx_uint_t eintr, complete;
- struct iovec *iov;
ngx_err_t err;
ngx_buf_t *file;
ngx_array_t header;
ngx_event_t *wev;
ngx_chain_t *cl;
+ struct iovec *iov, headers[NGX_HEADERS];
#if (HAVE_SENDFILE64)
off_t offset;
#else
@@ -48,6 +51,11 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
send = 0;
+ header.elts = headers;
+ header.size = sizeof(struct iovec);
+ header.nalloc = NGX_HEADERS;
+ header.pool = c->pool;
+
for ( ;; ) {
file = NULL;
fsize = 0;
@@ -55,8 +63,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
complete = 0;
sprev = send;
- ngx_init_array(header, c->pool, 10, sizeof(struct iovec),
- NGX_CHAIN_ERROR);
+ header.nelts = 0;
prev = NULL;
iov = NULL;
@@ -85,7 +92,10 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
iov->iov_len += size;
} else {
- ngx_test_null(iov, ngx_push_array(&header), NGX_CHAIN_ERROR);
+ if (!(iov = ngx_array_push(&header))) {
+ return NGX_CHAIN_ERROR;
+ }
+
iov->iov_base = (void *) cl->buf->pos;
iov->iov_len = size;
}
diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c
index 07a8a8d4e..d249e8186 100644
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -9,6 +9,9 @@
#include <ngx_event.h>
+#define NGX_SENDFILEVECS 16
+
+
ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
off_t limit)
{
@@ -19,7 +22,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
ssize_t n;
ngx_int_t eintr, complete;
ngx_err_t err;
- sendfilevec_t *sfv;
+ sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS];
ngx_array_t vec;
ngx_event_t *wev;
ngx_chain_t *cl, *tail;
@@ -33,6 +36,11 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
send = 0;
complete = 0;
+ vec.elts = sfvs;
+ vec.size = sizeof(sendfilevec_t);
+ vec.nalloc = NGX_SENDFILEVECS;
+ vec.pool = c->pool;
+
for ( ;; ) {
fd = SFV_FD_SELF;
prev = NULL;
@@ -42,8 +50,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sent = 0;
sprev = send;
- ngx_init_array(vec, c->pool, 10, sizeof(sendfilevec_t),
- NGX_CHAIN_ERROR);
+ vec.nelts = 0;
/* create the sendfilevec and coalesce the neighbouring bufs */
@@ -66,7 +73,10 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_len += size;
} else {
- ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR);
+ if (!(sfv = ngx_array_push(&vec))) {
+ return NGX_CHAIN_ERROR;
+ }
+
sfv->sfv_fd = SFV_FD_SELF;
sfv->sfv_flag = 0;
sfv->sfv_off = (off_t) (uintptr_t) cl->buf->pos;
@@ -96,7 +106,10 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_len += size;
} else {
- ngx_test_null(sfv, ngx_push_array(&vec), NGX_CHAIN_ERROR);
+ if (!(sfv = ngx_array_push(&vec))) {
+ return NGX_CHAIN_ERROR;
+ }
+
fd = cl->buf->file->fd;
sfv->sfv_fd = fd;
sfv->sfv_flag = 0;