aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_solaris_sendfilev_chain.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-12-02 18:40:46 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-12-02 18:40:46 +0000
commit42b12b34fa74c15cfb1746d71cde949f3d5807ef (patch)
treec44cd3f35d794e6e2be01d516e72737464f76fff /src/os/unix/ngx_solaris_sendfilev_chain.c
parent4e7b11b02bd42ed284a5f006a13b0635fc33d556 (diff)
downloadnginx-42b12b34fa74c15cfb1746d71cde949f3d5807ef.tar.gz
nginx-42b12b34fa74c15cfb1746d71cde949f3d5807ef.zip
nginx-0.1.11-RELEASE importrelease-0.1.11
*) Feature: the worker_priority directive. *) Change: both tcp_nopush and tcp_nodelay directives affect the transferred response. *) Bugfix: nginx did not call initgroups(). Thanks to Andrew Sitnikov and Andrei Nigmatulin. *) Change: now the ngx_http_autoindex_module shows the file size in the bytes. *) Bugfix: the ngx_http_autoindex_module returned the 500 error if the broken symlink was in a directory. *) Bugfix: the files bigger than 4G could not be transferred using sendfile. *) Bugfix: if the backend was resolved to several backends and there was an error while the response waiting then process may got caught in an endless loop. *) Bugfix: the worker process may exit with the "unknown cycle" message when the /dev/poll method was used. *) Bugfix: "close() channel failed" errors. *) Bugfix: the autodetection of the "nobody" and "nogroup" groups. *) Bugfix: the send_lowat directive did not work on Linux. *) Bugfix: the segmentation fault occurred if there was no events section in configuration. *) Bugfix: nginx could not be built on OpenBSD. *) Bugfix: the double slashes in "://" in the URI were converted to ":/".
Diffstat (limited to 'src/os/unix/ngx_solaris_sendfilev_chain.c')
-rw-r--r--src/os/unix/ngx_solaris_sendfilev_chain.c57
1 files changed, 44 insertions, 13 deletions
diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c
index 21f8b8f7c..4c873aa11 100644
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -9,6 +9,28 @@
#include <ngx_event.h>
+#if (NGX_TEST_BUILD_SOLARIS_SENDFILEV)
+
+/* Solaris declarations */
+
+typedef struct sendfilevec {
+ int sfv_fd;
+ u_int sfv_flag;
+ off_t sfv_off;
+ size_t sfv_len;
+} sendfilevec_t;
+
+#define SFV_FD_SELF -2
+
+static ssize_t sendfilev(int fd, const struct sendfilevec *vec,
+ int sfvcnt, size_t *xferred)
+{
+ return -1;
+}
+
+#endif
+
+
#define NGX_SENDFILEVECS 16
@@ -17,8 +39,9 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
{
int fd;
u_char *prev;
- off_t fprev, sprev, send, aligned;
- ssize_t size, sent, n;
+ off_t size, send, prev_send, aligned, fprev;
+ size_t sent;
+ ssize_t n;
ngx_int_t eintr, complete;
ngx_err_t err;
sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS];
@@ -36,6 +59,14 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
return ngx_writev_chain(c, in, limit);
}
+
+ /* the maximum limit size is the maximum size_t value - the page size */
+
+ if (limit == 0 || limit > MAX_SIZE_T_VALUE - ngx_pagesize) {
+ limit = MAX_SIZE_T_VALUE - ngx_pagesize;
+ }
+
+
send = 0;
complete = 0;
@@ -51,7 +82,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv = NULL;
eintr = 0;
sent = 0;
- sprev = send;
+ prev_send = send;
vec.nelts = 0;
@@ -73,7 +104,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
}
if (prev == cl->buf->pos) {
- sfv->sfv_len += size;
+ sfv->sfv_len += (size_t) size;
} else {
if (!(sfv = ngx_array_push(&vec))) {
@@ -83,16 +114,16 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_fd = SFV_FD_SELF;
sfv->sfv_flag = 0;
sfv->sfv_off = (off_t) (uintptr_t) cl->buf->pos;
- sfv->sfv_len = size;
+ sfv->sfv_len = (size_t) size;
}
- prev = cl->buf->pos + size;
+ prev = cl->buf->pos + (size_t) size;
send += size;
} else {
prev = NULL;
- size = (size_t) (cl->buf->file_last - cl->buf->file_pos);
+ size = cl->buf->file_last - cl->buf->file_pos;
if (send + size > limit) {
size = limit - send;
@@ -106,7 +137,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
}
if (fd == cl->buf->file->fd && fprev == cl->buf->file_pos) {
- sfv->sfv_len += size;
+ sfv->sfv_len += (size_t) size;
} else {
if (!(sfv = ngx_array_push(&vec))) {
@@ -117,7 +148,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_fd = fd;
sfv->sfv_flag = 0;
sfv->sfv_off = cl->buf->file_pos;
- sfv->sfv_len = size;
+ sfv->sfv_len = (size_t) size;
}
fprev = cl->buf->file_pos + size;
@@ -136,7 +167,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
}
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err,
- "sendfilev() sent only %z bytes", sent);
+ "sendfilev() sent only %uz bytes", sent);
} else {
wev->error = 1;
@@ -148,7 +179,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
"sendfilev: %z %z", n, sent);
- if (send - sprev == sent) {
+ if (send - prev_send == (off_t) sent) {
complete = 1;
}
@@ -166,8 +197,8 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
size = ngx_buf_size(cl->buf);
- if (sent >= size) {
- sent -= size;
+ if ((off_t) sent >= size) {
+ sent = (size_t) ((off_t) sent - size);
if (ngx_buf_in_memory(cl->buf)) {
cl->buf->pos = cl->buf->last;