aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_writev_chain.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-11-02 22:56:18 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-11-02 22:56:18 +0000
commit659774979feb9741a441505e26774b35830fd4ca (patch)
tree596059bbe20959ad54cbfde8bcdf24cd7f9e9f83 /src/os/unix/ngx_writev_chain.c
parentfe0f5cc6e1e48412235ae91c2f71ec2ec9110a60 (diff)
downloadnginx-659774979feb9741a441505e26774b35830fd4ca.tar.gz
nginx-659774979feb9741a441505e26774b35830fd4ca.zip
nginx-0.0.1-2003-11-03-01:56:18 import
Diffstat (limited to 'src/os/unix/ngx_writev_chain.c')
-rw-r--r--src/os/unix/ngx_writev_chain.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c
index 70141e341..6ead65f3a 100644
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -11,34 +11,34 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in)
off_t sent;
struct iovec *iov;
ngx_err_t err;
- ngx_array_t iovecs;
- ngx_chain_t *ce;
+ ngx_array_t io;
+ ngx_chain_t *cl;
if (!c->write->ready) {
return in;
}
- ngx_init_array(iovecs, c->pool, 10, sizeof(struct iovec), NGX_CHAIN_ERROR);
+ ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_CHAIN_ERROR);
prev = NULL;
iov = NULL;
- /* create the iovec and coalesce the neighbouring chain entries */
- for (ce = in; ce; ce = ce->next) {
+ /* create the iovec and coalesce the neighbouring hunks */
+ for (cl = in; cl; cl = cl->next) {
- if (prev == ce->hunk->pos) {
- iov->iov_len += ce->hunk->last - ce->hunk->pos;
- prev = ce->hunk->last;
+ if (prev == cl->hunk->pos) {
+ iov->iov_len += cl->hunk->last - cl->hunk->pos;
+ prev = cl->hunk->last;
} else {
- ngx_test_null(iov, ngx_push_array(&iovecs), NGX_CHAIN_ERROR);
- iov->iov_base = ce->hunk->pos;
- iov->iov_len = ce->hunk->last - ce->hunk->pos;
- prev = ce->hunk->last;
+ ngx_test_null(iov, ngx_push_array(&io), NGX_CHAIN_ERROR);
+ iov->iov_base = cl->hunk->pos;
+ iov->iov_len = cl->hunk->last - cl->hunk->pos;
+ prev = cl->hunk->last;
}
}
- n = writev(c->fd, iovecs.elts, iovecs.nelts);
+ n = writev(c->fd, io.elts, io.nelts);
if (n == -1) {
err = ngx_errno;
@@ -62,42 +62,40 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in)
c->sent += sent;
- for (ce = in; ce && sent > 0; ce = ce->next) {
+ for (cl = in; cl && sent > 0; cl = cl->next) {
- size = ce->hunk->last - ce->hunk->pos;
+ size = cl->hunk->last - cl->hunk->pos;
ngx_log_debug(c->log, "SIZE: %d" _ size);
if (sent >= size) {
sent -= size;
- if (ce->hunk->type & NGX_HUNK_IN_MEMORY) {
- ce->hunk->pos = ce->hunk->last;
+ if (cl->hunk->type & NGX_HUNK_IN_MEMORY) {
+ cl->hunk->pos = cl->hunk->last;
}
#if 0
- if (ce->hunk->type & NGX_HUNK_FILE) {
- ce->hunk->file_pos = ce->hunk->file_last;
+ if (cl->hunk->type & NGX_HUNK_FILE) {
+ cl->hunk->file_pos = cl->hunk->file_last;
}
#endif
continue;
}
- if (ce->hunk->type & NGX_HUNK_IN_MEMORY) {
- ce->hunk->pos += sent;
+ if (cl->hunk->type & NGX_HUNK_IN_MEMORY) {
+ cl->hunk->pos += sent;
}
#if 0
- if (ce->hunk->type & NGX_HUNK_FILE) {
- ce->hunk->file_pos += sent;
+ if (cl->hunk->type & NGX_HUNK_FILE) {
+ cl->hunk->file_pos += sent;
}
#endif
break;
}
- ngx_destroy_array(&iovecs);
-
- return ce;
+ return cl;
}