aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_aio_write_chain.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-06-21 15:59:32 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-06-21 15:59:32 +0000
commitef06648615d6ce6e000e6c737f80c2ba9fa04d3a (patch)
tree5f840689ca43ecba7218f9709f1bdfaa27611f53 /src/os/unix/ngx_aio_write_chain.c
parent73a73b5a60b1c6c985f3e9a5d7cddbe292ad01a4 (diff)
downloadnginx-ef06648615d6ce6e000e6c737f80c2ba9fa04d3a.tar.gz
nginx-ef06648615d6ce6e000e6c737f80c2ba9fa04d3a.zip
nginx-0.0.7-2004-06-21-19:59:32 import
Diffstat (limited to 'src/os/unix/ngx_aio_write_chain.c')
-rw-r--r--src/os/unix/ngx_aio_write_chain.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/os/unix/ngx_aio_write_chain.c b/src/os/unix/ngx_aio_write_chain.c
index a872fe2e0..2bfa59021 100644
--- a/src/os/unix/ngx_aio_write_chain.c
+++ b/src/os/unix/ngx_aio_write_chain.c
@@ -5,21 +5,24 @@
#include <ngx_aio.h>
-ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in)
+ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
+ off_t limit)
{
int n;
u_char *buf, *prev;
- off_t sent;
- size_t size;
+ off_t send, sent;
+ size_t len;
+ ssize_t size;
ngx_err_t err;
ngx_chain_t *cl;
+ send = 0;
sent = 0;
cl = in;
while (cl) {
- if (cl->buf->last - cl->buf->pos == 0) {
+ if (cl->buf->pos == cl->buf->last) {
cl = cl->next;
continue;
}
@@ -32,17 +35,28 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in)
buf = cl->buf->pos;
prev = buf;
- size = 0;
+ len = 0;
/* coalesce the neighbouring bufs */
- while (cl && prev == cl->buf->pos) {
- size += cl->buf->last - cl->buf->pos;
- prev = cl->buf->last;
+ 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, size);
+ n = ngx_aio_write(c, buf, len);
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_write: %d", n);