2003-10-27 16:53:49 +08:00
|
|
|
|
2004-09-28 16:34:51 +08:00
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-10-27 16:53:49 +08:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
2003-10-28 05:01:00 +08:00
|
|
|
#include <ngx_event.h>
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
#if 0
|
|
|
|
#define NGX_SENDFILE_LIMIT 4096
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define NGX_NONE 1
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
static ngx_inline ngx_int_t
|
2004-06-16 23:32:11 +08:00
|
|
|
ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf);
|
2004-11-26 00:17:31 +08:00
|
|
|
static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
|
|
|
|
ngx_chain_t **chain, ngx_chain_t *in);
|
2004-05-28 23:49:23 +08:00
|
|
|
static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
|
|
|
|
ngx_uint_t sendfile);
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
|
2004-06-16 23:32:11 +08:00
|
|
|
ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
|
2003-10-27 16:53:49 +08:00
|
|
|
{
|
|
|
|
int rc, last;
|
2004-12-03 02:40:46 +08:00
|
|
|
off_t bsize;
|
|
|
|
size_t size;
|
2003-10-27 16:53:49 +08:00
|
|
|
ngx_chain_t *cl, *out, **last_out;
|
|
|
|
|
2004-10-21 23:34:38 +08:00
|
|
|
if (ctx->in == NULL && ctx->busy == NULL) {
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
/*
|
|
|
|
* the short path for the case when the ctx->in and ctx->busy chains
|
|
|
|
* are empty, the incoming chain is empty too or has the single buf
|
|
|
|
* that does not require the copy
|
|
|
|
*/
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
if (in == NULL) {
|
2004-03-23 14:01:52 +08:00
|
|
|
return ctx->output_filter(ctx->filter_ctx, in);
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
|
2003-10-28 05:01:00 +08:00
|
|
|
if (in->next == NULL
|
2004-11-26 00:17:31 +08:00
|
|
|
#if (NGX_SENDFILE_LIMIT)
|
|
|
|
&& !(in->buf->in_file && in->buf->file_last > NGX_SENDFILE_LIMIT)
|
|
|
|
#endif
|
2004-05-28 23:49:23 +08:00
|
|
|
&& (!ngx_output_chain_need_to_copy(ctx, in->buf)))
|
2003-10-27 16:53:49 +08:00
|
|
|
{
|
2004-03-23 14:01:52 +08:00
|
|
|
return ctx->output_filter(ctx->filter_ctx, in);
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-01 14:04:46 +08:00
|
|
|
/* add the incoming buf to the chain ctx->in */
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
if (in) {
|
2004-11-26 00:17:31 +08:00
|
|
|
if (ngx_output_chain_add_copy(ctx->pool, &ctx->in, in) == NGX_ERROR) {
|
2003-10-27 16:53:49 +08:00
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
last = NGX_NONE;
|
2003-10-29 16:30:44 +08:00
|
|
|
out = NULL;
|
2003-10-27 16:53:49 +08:00
|
|
|
last_out = &out;
|
|
|
|
|
|
|
|
for ( ;; ) {
|
|
|
|
|
|
|
|
while (ctx->in) {
|
|
|
|
|
2004-04-19 03:06:02 +08:00
|
|
|
/*
|
2004-05-28 23:49:23 +08:00
|
|
|
* cycle while there are the ctx->in bufs
|
|
|
|
* or there are the free output bufs to copy in
|
2004-04-19 03:06:02 +08:00
|
|
|
*/
|
|
|
|
|
2004-07-29 03:21:26 +08:00
|
|
|
bsize = ngx_buf_size(ctx->in->buf);
|
|
|
|
|
|
|
|
if (bsize == 0 && !ngx_buf_special(ctx->in->buf)) {
|
|
|
|
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0,
|
nginx-0.1.14-RELEASE import
*) Feature: the autoconfiguration directives:
--http-client-body-temp-path=PATH, --http-proxy-temp-path=PATH, and
--http-fastcgi-temp-path=PATH
*) Change: the directory name for the temporary files with the client
request body is specified by directive client_body_temp_path, by
default it is <prefix>/client_body_temp.
*) Feature: the ngx_http_fastcgi_module and the directives:
fastcgi_pass, fastcgi_root, fastcgi_index, fastcgi_params,
fastcgi_connect_timeout, fastcgi_send_timeout, fastcgi_read_timeout,
fastcgi_send_lowat, fastcgi_header_buffer_size, fastcgi_buffers,
fastcgi_busy_buffers_size, fastcgi_temp_path,
fastcgi_max_temp_file_size, fastcgi_temp_file_write_size,
fastcgi_next_upstream, and fastcgi_x_powered_by.
*) Bugfix: the "[alert] zero size buf" error; the bug had appeared in
0.1.3.
*) Change: the URI must be specified after the host name in the
proxy_pass directive.
*) Change: the %3F symbol in the URI was considered as the argument
string start.
*) Feature: the unix domain sockets support in the
ngx_http_proxy_module.
*) Feature: the ssl_engine and ssl_ciphers directives.
Thanks to Sergey Skvortsov for SSL-accelerator.
2005-01-18 21:03:58 +08:00
|
|
|
"zero size buf in output");
|
2004-07-29 03:21:26 +08:00
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
ngx_debug_point();
|
|
|
|
|
2004-07-29 03:21:26 +08:00
|
|
|
ctx->in = ctx->in->next;
|
2004-09-20 02:27:00 +08:00
|
|
|
|
2004-07-29 03:21:26 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (!ngx_output_chain_need_to_copy(ctx, ctx->in->buf)) {
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-04-19 03:06:02 +08:00
|
|
|
/* move the chain link to the output chain */
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
cl = ctx->in;
|
|
|
|
ctx->in = cl->next;
|
|
|
|
|
|
|
|
*last_out = cl;
|
|
|
|
last_out = &cl->next;
|
|
|
|
cl->next = NULL;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (ctx->buf == NULL) {
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
/* get the free buf */
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
if (ctx->free) {
|
2004-05-28 23:49:23 +08:00
|
|
|
ctx->buf = ctx->free->buf;
|
2003-10-27 16:53:49 +08:00
|
|
|
ctx->free = ctx->free->next;
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
} else if (out || ctx->allocated == ctx->bufs.num) {
|
2004-05-12 13:37:55 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else {
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
size = ctx->bufs.size;
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (ctx->in->buf->last_buf) {
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
if (bsize < (off_t) ctx->bufs.size) {
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
/*
|
2004-05-28 23:49:23 +08:00
|
|
|
* allocate small temp buf for the small last buf
|
2003-10-27 16:53:49 +08:00
|
|
|
* or its small last part
|
|
|
|
*/
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
size = (size_t) bsize;
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
} else if (ctx->bufs.num == 1
|
2004-12-03 02:40:46 +08:00
|
|
|
&& (bsize < (off_t) (ctx->bufs.size
|
|
|
|
+ (ctx->bufs.size >> 2))))
|
2003-10-27 16:53:49 +08:00
|
|
|
{
|
|
|
|
/*
|
2004-05-28 23:49:23 +08:00
|
|
|
* allocate a temp buf that equals
|
|
|
|
* to the last buf if the last buf size is lesser
|
|
|
|
* than 1.25 of bufs.size and a temp buf is single
|
2003-10-27 16:53:49 +08:00
|
|
|
*/
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
size = (size_t) bsize;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (!(ctx->buf = ngx_create_temp_buf(ctx->pool, size))) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->buf->tag = ctx->tag;
|
|
|
|
ctx->buf->recycled = 1;
|
|
|
|
ctx->allocated++;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
rc = ngx_output_chain_copy_buf(ctx->buf, ctx->in->buf,
|
|
|
|
ctx->sendfile);
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
if (rc == NGX_ERROR) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == NGX_AGAIN) {
|
|
|
|
if (out) {
|
|
|
|
break;
|
|
|
|
}
|
2004-09-20 02:27:00 +08:00
|
|
|
|
2003-10-27 16:53:49 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
/* delete the completed buf from the ctx->in chain */
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (ngx_buf_size(ctx->in->buf) == 0) {
|
2003-10-27 16:53:49 +08:00
|
|
|
ctx->in = ctx->in->next;
|
|
|
|
}
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
if (!(cl = ngx_alloc_chain_link(ctx->pool))) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
cl->buf = ctx->buf;
|
|
|
|
cl->next = NULL;
|
2003-10-27 16:53:49 +08:00
|
|
|
*last_out = cl;
|
|
|
|
last_out = &cl->next;
|
2004-05-28 23:49:23 +08:00
|
|
|
ctx->buf = NULL;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (out == NULL && last != NGX_NONE) {
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
|
2004-03-23 14:01:52 +08:00
|
|
|
last = ctx->output_filter(ctx->filter_ctx, out);
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
ngx_chain_update_chains(&ctx->free, &ctx->busy, &out, ctx->tag);
|
|
|
|
last_out = &out;
|
2004-04-19 03:06:02 +08:00
|
|
|
|
|
|
|
if (last == NGX_ERROR) {
|
|
|
|
return last;
|
|
|
|
}
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-21 03:52:20 +08:00
|
|
|
static ngx_inline ngx_int_t
|
2004-06-16 23:32:11 +08:00
|
|
|
ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf)
|
2003-10-27 16:53:49 +08:00
|
|
|
{
|
2004-11-26 00:17:31 +08:00
|
|
|
ngx_uint_t sendfile;
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (ngx_buf_special(buf)) {
|
2003-10-27 16:53:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
sendfile = ctx->sendfile;
|
|
|
|
|
|
|
|
#if (NGX_SENDFILE_LIMIT)
|
|
|
|
|
|
|
|
if (buf->in_file && buf->file_pos >= NGX_SENDFILE_LIMIT) {
|
|
|
|
sendfile = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!sendfile) {
|
2004-10-21 23:34:38 +08:00
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (!ngx_buf_in_memory(buf)) {
|
2003-11-03 06:56:18 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
buf->in_file = 0;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (ctx->need_in_memory && !ngx_buf_in_memory(buf)) {
|
2003-10-27 16:53:49 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (ctx->need_in_temp && (buf->memory || buf->mmap)) {
|
2003-10-27 16:53:49 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
|
|
|
|
ngx_chain_t **chain, ngx_chain_t *in)
|
|
|
|
{
|
|
|
|
ngx_chain_t *cl, **ll;
|
|
|
|
#if (NGX_SENDFILE_LIMIT)
|
|
|
|
ngx_buf_t *b, *buf;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ll = chain;
|
|
|
|
|
|
|
|
for (cl = *chain; cl; cl = cl->next) {
|
|
|
|
ll = &cl->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (in) {
|
|
|
|
|
|
|
|
if (!(cl = ngx_alloc_chain_link(pool))) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (NGX_SENDFILE_LIMIT)
|
|
|
|
|
|
|
|
buf = in->buf;
|
|
|
|
|
|
|
|
if (buf->in_file
|
|
|
|
&& buf->file_pos < NGX_SENDFILE_LIMIT
|
|
|
|
&& buf->file_last > NGX_SENDFILE_LIMIT)
|
|
|
|
{
|
|
|
|
if (!(b = ngx_calloc_buf(pool))) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_memcpy(b, buf, sizeof(ngx_buf_t));
|
|
|
|
|
|
|
|
if (ngx_buf_in_memory(buf)) {
|
|
|
|
buf->pos += (ssize_t) (NGX_SENDFILE_LIMIT - buf->file_pos);
|
|
|
|
b->last = buf->pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf->file_pos = NGX_SENDFILE_LIMIT;
|
|
|
|
b->file_last = NGX_SENDFILE_LIMIT;
|
|
|
|
|
|
|
|
cl->buf = b;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
cl->buf = buf;
|
|
|
|
in = in->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
cl->buf = in->buf;
|
|
|
|
in = in->next;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
*ll = cl;
|
|
|
|
ll = &cl->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ll = NULL;
|
|
|
|
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
|
|
|
|
ngx_uint_t sendfile)
|
2003-10-27 16:53:49 +08:00
|
|
|
{
|
2004-12-03 02:40:46 +08:00
|
|
|
off_t size;
|
2003-11-21 14:30:49 +08:00
|
|
|
ssize_t n;
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
size = ngx_buf_size(src);
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
if (size > dst->end - dst->pos) {
|
2003-10-27 16:53:49 +08:00
|
|
|
size = dst->end - dst->pos;
|
|
|
|
}
|
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
#if (NGX_SENDFILE_LIMIT)
|
|
|
|
|
|
|
|
if (src->in_file && src->file_pos >= NGX_SENDFILE_LIMIT) {
|
|
|
|
sendfile = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (ngx_buf_in_memory(src)) {
|
2004-12-03 02:40:46 +08:00
|
|
|
ngx_memcpy(dst->pos, src->pos, (size_t) size);
|
|
|
|
src->pos += (size_t) size;
|
|
|
|
dst->last += (size_t) size;
|
2003-10-27 16:53:49 +08:00
|
|
|
|
2004-10-21 23:34:38 +08:00
|
|
|
if (src->in_file) {
|
|
|
|
|
|
|
|
if (sendfile) {
|
|
|
|
dst->in_file = 1;
|
|
|
|
dst->file = src->file;
|
|
|
|
dst->file_pos = src->file_pos;
|
|
|
|
dst->file_last = src->file_pos + size;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
dst->in_file = 0;
|
|
|
|
}
|
|
|
|
|
2003-10-27 16:53:49 +08:00
|
|
|
src->file_pos += size;
|
2004-10-11 23:07:03 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
dst->in_file = 0;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (src->last_buf && src->pos == src->last) {
|
|
|
|
dst->last_buf = 1;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2004-12-03 02:40:46 +08:00
|
|
|
n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos);
|
2003-10-27 16:53:49 +08:00
|
|
|
|
|
|
|
if (n == NGX_ERROR) {
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (NGX_FILE_AIO_READ)
|
|
|
|
if (n == NGX_AGAIN) {
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
if (n != size) {
|
2003-10-27 16:53:49 +08:00
|
|
|
ngx_log_error(NGX_LOG_ALERT, src->file->log, 0,
|
2004-12-03 02:40:46 +08:00
|
|
|
ngx_read_file_n " reads only %z of %O from file",
|
2003-10-27 16:53:49 +08:00
|
|
|
n, size);
|
|
|
|
if (n == 0) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->last += n;
|
|
|
|
|
2004-10-11 23:07:03 +08:00
|
|
|
if (sendfile) {
|
|
|
|
dst->in_file = 1;
|
|
|
|
dst->file = src->file;
|
|
|
|
dst->file_pos = src->file_pos;
|
2004-10-21 23:34:38 +08:00
|
|
|
dst->file_last = src->file_pos + n;
|
2004-10-11 23:07:03 +08:00
|
|
|
|
|
|
|
} else {
|
2004-05-28 23:49:23 +08:00
|
|
|
dst->in_file = 0;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
|
2004-10-21 23:34:38 +08:00
|
|
|
src->file_pos += n;
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
if (src->last_buf && src->file_pos == src->file_last) {
|
|
|
|
dst->last_buf = 1;
|
2003-10-27 16:53:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
2003-10-28 05:01:00 +08:00
|
|
|
|
|
|
|
|
2004-05-28 23:49:23 +08:00
|
|
|
ngx_int_t ngx_chain_writer(void *data, ngx_chain_t *in)
|
2003-10-28 05:01:00 +08:00
|
|
|
{
|
2003-10-30 16:51:06 +08:00
|
|
|
ngx_chain_writer_ctx_t *ctx = data;
|
2003-10-28 05:01:00 +08:00
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
off_t size;
|
2003-10-28 05:01:00 +08:00
|
|
|
ngx_chain_t *cl;
|
|
|
|
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
for (size = 0; in; in = in->next) {
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
if (ngx_buf_size(in->buf) == 0 && !ngx_buf_special(in->buf)) {
|
|
|
|
ngx_debug_point();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
size += ngx_buf_size(in->buf);
|
2004-08-27 23:40:59 +08:00
|
|
|
|
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->connection->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"chain writer buf size: %uz", ngx_buf_size(in->buf));
|
2004-08-27 23:40:59 +08:00
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
if (!(cl = ngx_alloc_chain_link(ctx->pool))) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
cl->buf = in->buf;
|
|
|
|
cl->next = NULL;
|
2003-10-28 05:01:00 +08:00
|
|
|
*ctx->last = cl;
|
|
|
|
ctx->last = &cl->next;
|
|
|
|
}
|
|
|
|
|
2004-03-16 21:35:20 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->connection->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"chain writer in: %p", ctx->out);
|
2004-03-16 21:35:20 +08:00
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
for (cl = ctx->out; cl; cl = cl->next) {
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
if (ngx_buf_size(cl->buf) == 0 && !ngx_buf_special(cl->buf)) {
|
|
|
|
ngx_debug_point();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
size += ngx_buf_size(cl->buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size == 0) {
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
2004-07-17 01:11:43 +08:00
|
|
|
ctx->out = ngx_send_chain(ctx->connection, ctx->out, ctx->limit);
|
2003-10-28 05:01:00 +08:00
|
|
|
|
2004-03-16 21:35:20 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->connection->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"chain writer out: %p", ctx->out);
|
2004-03-16 21:35:20 +08:00
|
|
|
|
2003-10-28 05:01:00 +08:00
|
|
|
if (ctx->out == NGX_CHAIN_ERROR) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->out == NULL) {
|
|
|
|
ctx->last = &ctx->out;
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_AGAIN;
|
|
|
|
}
|