nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index b31166e..279001b 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -40,7 +40,7 @@
} ngx_http_charset_ctx_t;
-static void ngx_charset_recode(ngx_hunk_t *h, char *table);
+static void ngx_charset_recode(ngx_buf_t *b, char *table);
static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
@@ -50,7 +50,7 @@
void *conf);
static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name);
-static int ngx_http_charset_filter_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle);
static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf);
static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf);
@@ -212,18 +212,18 @@
table = charsets[lcf->source_charset].tables[lcf->default_charset];
for (cl = in; cl; cl = cl->next) {
- ngx_charset_recode(cl->hunk, table);
+ ngx_charset_recode(cl->buf, table);
}
return ngx_http_next_body_filter(r, in);
}
-static void ngx_charset_recode(ngx_hunk_t *h, char *table)
+static void ngx_charset_recode(ngx_buf_t *b, char *table)
{
u_char *p, c;
- for (p = h->pos; p < h->last; p++) {
+ for (p = b->pos; p < b->last; p++) {
c = *p;
*p = table[c];
}
@@ -412,7 +412,7 @@
}
-static int ngx_http_charset_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle)
{
ngx_http_next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ngx_http_charset_header_filter;
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c
index 70e0fcd..c429fa8 100644
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -58,14 +58,14 @@
{
u_char *chunk;
size_t size, len;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t out, tail, *cl, *tl, **ll;
if (in == NULL || !r->chunked) {
return ngx_http_next_body_filter(r, in);
}
- out.hunk = NULL;
+ out.buf = NULL;
ll = &out.next;
size = 0;
@@ -73,12 +73,12 @@
for ( ;; ) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http chunk: %d", ngx_hunk_size(cl->hunk));
+ "http chunk: %d", ngx_buf_size(cl->buf));
- size += ngx_hunk_size(cl->hunk);
+ size += ngx_buf_size(cl->buf);
ngx_test_null(tl, ngx_alloc_chain_link(r->pool), NGX_ERROR);
- tl->hunk = cl->hunk;
+ tl->buf = cl->buf;
*ll = tl;
ll = &tl->next;
@@ -93,25 +93,26 @@
ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
- h->pos = chunk;
- h->last = chunk + len;
+ ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+ b->temporary = 1;
+ b->pos = chunk;
+ b->last = chunk + len;
- out.hunk = h;
+ out.buf = b;
}
- if (cl->hunk->type & NGX_HUNK_LAST) {
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY|NGX_HUNK_LAST;
- h->pos = (u_char *) CRLF "0" CRLF CRLF;
- h->last = h->pos + 7;
+ if (cl->buf->last_buf) {
+ ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+ b->memory = 1;
+ b->last_buf = 1;
+ b->pos = (u_char *) CRLF "0" CRLF CRLF;
+ b->last = b->pos + 7;
- cl->hunk->type &= ~NGX_HUNK_LAST;
+ cl->buf->last_buf = 0;
if (size == 0) {
- h->pos += 2;
- out.hunk = h;
+ b->pos += 2;
+ out.buf = b;
out.next = NULL;
return ngx_http_next_body_filter(r, &out);
@@ -123,13 +124,13 @@
return ngx_http_next_body_filter(r, out.next);
}
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY;
- h->pos = (u_char *) CRLF;
- h->last = h->pos + 2;
+ ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+ b->memory = 1;
+ b->pos = (u_char *) CRLF;
+ b->last = b->pos + 2;
}
- tail.hunk = h;
+ tail.buf = b;
tail.next = NULL;
*ll = &tail;
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index 76b07bf..4f43f34 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -39,9 +39,9 @@
ngx_chain_t *busy;
ngx_chain_t *out;
ngx_chain_t **last_out;
- ngx_hunk_t *in_hunk;
- ngx_hunk_t *out_hunk;
- ngx_int_t hunks;
+ ngx_buf_t *in_buf;
+ ngx_buf_t *out_buf;
+ ngx_int_t bufs;
off_t length;
@@ -407,7 +407,7 @@
{
int rc, wbits, memlevel, last;
struct gztrailer *trailer;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t *cl;
ngx_http_gzip_ctx_t *ctx;
ngx_http_gzip_conf_t *conf;
@@ -465,13 +465,13 @@
return ngx_http_gzip_error(ctx);
}
- ngx_test_null(h, ngx_calloc_hunk(r->pool), ngx_http_gzip_error(ctx));
+ ngx_test_null(b, ngx_calloc_buf(r->pool), ngx_http_gzip_error(ctx));
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY;
- h->pos = gzheader;
- h->last = h->pos + 10;
+ b->memory = 1;
+ b->pos = gzheader;
+ b->last = b->pos + 10;
- ngx_alloc_link_and_set_hunk(cl, h, r->pool, ngx_http_gzip_error(ctx));
+ ngx_alloc_link_and_set_buf(cl, b, r->pool, ngx_http_gzip_error(ctx));
ctx->out = cl;
ctx->last_out = &cl->next;
@@ -504,29 +504,29 @@
break;
}
- ctx->in_hunk = ctx->in->hunk;
+ ctx->in_buf = ctx->in->buf;
ctx->in = ctx->in->next;
- ctx->zstream.next_in = ctx->in_hunk->pos;
- ctx->zstream.avail_in = ctx->in_hunk->last - ctx->in_hunk->pos;
+ ctx->zstream.next_in = ctx->in_buf->pos;
+ ctx->zstream.avail_in = ctx->in_buf->last - ctx->in_buf->pos;
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "gzip in_hunk:" PTR_FMT " ni:" PTR_FMT " ai:%d",
- ctx->in_hunk,
+ "gzip in_buf:" PTR_FMT " ni:" PTR_FMT " ai:%d",
+ ctx->in_buf,
ctx->zstream.next_in, ctx->zstream.avail_in);
/* STUB */
- if (ctx->in_hunk->last < ctx->in_hunk->pos) {
+ if (ctx->in_buf->last < ctx->in_buf->pos) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"zstream.avail_in is huge");
ctx->done = 1;
return NGX_ERROR;
}
- if (ctx->in_hunk->type & NGX_HUNK_LAST) {
+ if (ctx->in_buf->last_buf) {
ctx->flush = Z_FINISH;
- } else if (ctx->in_hunk->type & NGX_HUNK_FLUSH) {
+ } else if (ctx->in_buf->flush) {
ctx->flush = Z_SYNC_FLUSH;
}
@@ -545,17 +545,17 @@
if (ctx->zstream.avail_out == 0) {
if (ctx->free) {
- ctx->out_hunk = ctx->free->hunk;
+ ctx->out_buf = ctx->free->buf;
ctx->free = ctx->free->next;
- } else if (ctx->hunks < conf->bufs.num) {
- ngx_test_null(ctx->out_hunk,
- ngx_create_temp_hunk(r->pool, conf->bufs.size),
- ngx_http_gzip_error(ctx));
- ctx->out_hunk->tag = (ngx_hunk_tag_t)
+ } else if (ctx->bufs < conf->bufs.num) {
+ ngx_test_null(ctx->out_buf,
+ ngx_create_temp_buf(r->pool, conf->bufs.size),
+ ngx_http_gzip_error(ctx));
+ ctx->out_buf->tag = (ngx_buf_tag_t)
&ngx_http_gzip_filter_module;
- ctx->out_hunk->type |= NGX_HUNK_RECYCLED;
- ctx->hunks++;
+ ctx->out_buf->recycled = 1;
+ ctx->bufs++;
} else {
ctx->blocked = 1;
@@ -563,7 +563,7 @@
}
ctx->blocked = 0;
- ctx->zstream.next_out = ctx->out_hunk->pos;
+ ctx->zstream.next_out = ctx->out_buf->pos;
ctx->zstream.avail_out = conf->bufs.size;
}
@@ -587,23 +587,23 @@
rc);
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "gzip in_hunk:" PTR_FMT " pos:" PTR_FMT,
- ctx->in_hunk, ctx->in_hunk->pos);
+ "gzip in_buf:" PTR_FMT " pos:" PTR_FMT,
+ ctx->in_buf, ctx->in_buf->pos);
if (ctx->zstream.next_in) {
- ctx->in_hunk->pos = ctx->zstream.next_in;
+ ctx->in_buf->pos = ctx->zstream.next_in;
if (ctx->zstream.avail_in == 0) {
ctx->zstream.next_in = NULL;
}
}
- ctx->out_hunk->last = ctx->zstream.next_out;
+ ctx->out_buf->last = ctx->zstream.next_out;
if (ctx->zstream.avail_out == 0) {
- ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool,
- ngx_http_gzip_error(ctx));
+ ngx_alloc_link_and_set_buf(cl, ctx->out_buf, r->pool,
+ ngx_http_gzip_error(ctx));
*ctx->last_out = cl;
ctx->last_out = &cl->next;
ctx->redo = 1;
@@ -614,11 +614,11 @@
ctx->redo = 0;
if (ctx->flush == Z_SYNC_FLUSH) {
- ctx->out_hunk->type |= NGX_HUNK_FLUSH;
+ ctx->out_buf->flush = 0;
ctx->flush = Z_NO_FLUSH;
- ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool,
- ngx_http_gzip_error(ctx));
+ ngx_alloc_link_and_set_buf(cl, ctx->out_buf, r->pool,
+ ngx_http_gzip_error(ctx));
*ctx->last_out = cl;
ctx->last_out = &cl->next;
ctx->pass = 1;
@@ -640,28 +640,28 @@
ngx_pfree(r->pool, ctx->preallocated);
- ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool,
- ngx_http_gzip_error(ctx));
+ ngx_alloc_link_and_set_buf(cl, ctx->out_buf, r->pool,
+ ngx_http_gzip_error(ctx));
*ctx->last_out = cl;
ctx->last_out = &cl->next;
if (ctx->zstream.avail_out >= 8) {
- trailer = (struct gztrailer *) ctx->out_hunk->last;
- ctx->out_hunk->type |= NGX_HUNK_LAST;
- ctx->out_hunk->last += 8;
+ trailer = (struct gztrailer *) ctx->out_buf->last;
+ ctx->out_buf->last += 8;
+ ctx->out_buf->last_buf = 1;
} else {
- ngx_test_null(h, ngx_create_temp_hunk(r->pool, 8),
+ ngx_test_null(b, ngx_create_temp_buf(r->pool, 8),
ngx_http_gzip_error(ctx));
- h->type |= NGX_HUNK_LAST;
+ b->last_buf = 1;
- ngx_alloc_link_and_set_hunk(cl, h, r->pool,
- ngx_http_gzip_error(ctx));
+ ngx_alloc_link_and_set_buf(cl, b, r->pool,
+ ngx_http_gzip_error(ctx));
*ctx->last_out = cl;
ctx->last_out = &cl->next;
- trailer = (struct gztrailer *) h->pos;
- h->last += 8;
+ trailer = (struct gztrailer *) b->pos;
+ b->last += 8;
}
#if (HAVE_LITTLE_ENDIAN)
@@ -681,8 +681,8 @@
}
if (conf->no_buffer && ctx->in == NULL) {
- ngx_alloc_link_and_set_hunk(cl, ctx->out_hunk, r->pool,
- ngx_http_gzip_error(ctx));
+ ngx_alloc_link_and_set_buf(cl, ctx->out_buf, r->pool,
+ ngx_http_gzip_error(ctx));
*ctx->last_out = cl;
ctx->last_out = &cl->next;
ctx->pass = 1;
@@ -719,7 +719,7 @@
}
ngx_chain_update_chains(&ctx->free, &ctx->busy, &ctx->out,
- (ngx_hunk_tag_t) &ngx_http_gzip_filter_module);
+ (ngx_buf_tag_t) &ngx_http_gzip_filter_module);
ctx->last_out = &ctx->out;
if (ctx->done) {
diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c
index ecb42ad..484bcb0 100644
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -406,7 +406,7 @@
ngx_chain_t *in)
{
ngx_uint_t i;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t *out, *hcl, *rcl, *dcl, **ll;
ngx_http_range_t *range;
ngx_http_range_filter_ctx_t *ctx;
@@ -417,18 +417,15 @@
/*
* the optimized version for the static files only
- * that are passed in the single file hunk
+ * that are passed in the single file buf
*/
- if (in
- && in->hunk->type & NGX_HUNK_FILE
- && in->hunk->type & NGX_HUNK_LAST)
- {
+ if (in && in->buf->in_file && in->buf->last_buf) {
range = r->headers_out.ranges.elts;
if (r->headers_out.ranges.nelts == 1) {
- in->hunk->file_pos = range->start;
- in->hunk->file_last = range->end;
+ in->buf->file_pos = range->start;
+ in->buf->file_last = range->end;
return ngx_http_next_body_filter(r, in);
}
@@ -446,33 +443,33 @@
* "Content-Range: bytes "
*/
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY;
- h->pos = ctx->boundary_header.data;
- h->last = ctx->boundary_header.data + ctx->boundary_header.len;
+ ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+ b->memory = 1;
+ b->pos = ctx->boundary_header.data;
+ b->last = ctx->boundary_header.data + ctx->boundary_header.len;
ngx_test_null(hcl, ngx_alloc_chain_link(r->pool), NGX_ERROR);
- hcl->hunk = h;
+ hcl->buf = b;
/* "SSSS-EEEE/TTTT" CRLF CRLF */
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
- h->pos = range[i].content_range.data;
- h->last = range[i].content_range.data + range[i].content_range.len;
+ ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+ b->temporary = 1;
+ b->pos = range[i].content_range.data;
+ b->last = range[i].content_range.data + range[i].content_range.len;
ngx_test_null(rcl, ngx_alloc_chain_link(r->pool), NGX_ERROR);
- rcl->hunk = h;
+ rcl->buf = b;
/* the range data */
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_FILE;
- h->file_pos = range[i].start;
- h->file_last = range[i].end;
- h->file = in->hunk->file;
+ ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+ b->in_file = 1;
+ b->file_pos = range[i].start;
+ b->file_last = range[i].end;
+ b->file = in->buf->file;
- ngx_alloc_link_and_set_hunk(dcl, h, r->pool, NGX_ERROR);
+ ngx_alloc_link_and_set_buf(dcl, b, r->pool, NGX_ERROR);
*ll = hcl;
hcl->next = rcl;
@@ -482,14 +479,15 @@
/* the last boundary CRLF "--0123456789--" CRLF */
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP|NGX_HUNK_LAST;
- ngx_test_null(h->pos, ngx_palloc(r->pool, 4 + 10 + 4), NGX_ERROR);
- h->last = ngx_cpymem(h->pos, ctx->boundary_header.data, 4 + 10);
- *h->last++ = '-'; *h->last++ = '-';
- *h->last++ = CR; *h->last++ = LF;
+ ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+ b->temporary = 1;
+ b->last_buf = 1;
+ ngx_test_null(b->pos, ngx_palloc(r->pool, 4 + 10 + 4), NGX_ERROR);
+ b->last = ngx_cpymem(b->pos, ctx->boundary_header.data, 4 + 10);
+ *b->last++ = '-'; *b->last++ = '-';
+ *b->last++ = CR; *b->last++ = LF;
- ngx_alloc_link_and_set_hunk(hcl, h, r->pool, NGX_ERROR);
+ ngx_alloc_link_and_set_buf(hcl, b, r->pool, NGX_ERROR);
*ll = hcl;
return ngx_http_next_body_filter(r, out);
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index d06113b..532e8fa 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -67,7 +67,7 @@
ngx_str_t name, location;
ngx_err_t err;
ngx_log_t *log;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t out;
ngx_file_info_t fi;
ngx_http_cleanup_t *file_cleanup, *redirect_cleanup;
@@ -472,11 +472,11 @@
/* we need to allocate all before the header would be sent */
- if (!(h = ngx_pcalloc(r->pool, sizeof(ngx_hunk_t)))) {
+ if (!(b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)))) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- if (!(h->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)))) {
+ if (!(b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)))) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
@@ -487,15 +487,19 @@
return rc;
}
- h->type = r->main ? NGX_HUNK_FILE : NGX_HUNK_FILE|NGX_HUNK_LAST;
+ b->in_file = 1;
- h->file_pos = 0;
- h->file_last = ngx_file_size(&fi);
+ if (!r->main) {
+ b->last_buf = 1;
+ }
- h->file->fd = fd;
- h->file->log = log;
+ b->file_pos = 0;
+ b->file_last = ngx_file_size(&fi);
- out.hunk = h;
+ b->file->fd = fd;
+ b->file->log = log;
+
+ out.buf = b;
out.next = NULL;
return ngx_http_output_filter(r, &out);
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index e0f85ee..c89e971 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -159,7 +159,7 @@
ngx_http_proxy_upstream_t *upstream;
ngx_http_proxy_cache_t *cache;
- ngx_hunk_t *header_in;
+ ngx_buf_t *header_in;
ngx_http_busy_lock_ctx_t busy_lock;
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 60c9e8f..ed25c8e 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -108,7 +108,7 @@
{
size_t len;
ngx_uint_t i;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t *chain;
ngx_table_elt_t *header;
ngx_http_request_t *r;
@@ -177,71 +177,73 @@
len += header[i].key.len + 2 + header[i].value.len + 2;
}
- /* STUB */ len++;
+#if (NGX_DEBUG)
+ len++;
+#endif
- ngx_test_null(h, ngx_create_temp_hunk(r->pool, len), NULL);
- ngx_alloc_link_and_set_hunk(chain, h, r->pool, NULL);
+ ngx_test_null(b, ngx_create_temp_buf(r->pool, len), NULL);
+ ngx_alloc_link_and_set_buf(chain, b, r->pool, NULL);
/* the request line */
if (p->upstream->method) {
- h->last = ngx_cpymem(h->last,
+ b->last = ngx_cpymem(b->last,
http_methods[p->upstream->method - 1].data,
http_methods[p->upstream->method - 1].len);
} else {
- h->last = ngx_cpymem(h->last, r->method_name.data, r->method_name.len);
+ b->last = ngx_cpymem(b->last, r->method_name.data, r->method_name.len);
}
- h->last = ngx_cpymem(h->last, uc->uri.data, uc->uri.len);
+ b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len);
- h->last = ngx_cpymem(h->last,
+ b->last = ngx_cpymem(b->last,
r->uri.data + uc->location->len,
r->uri.len - uc->location->len);
if (r->args.len > 0) {
- *(h->last++) = '?';
- h->last = ngx_cpymem(h->last, r->args.data, r->args.len);
+ *(b->last++) = '?';
+ b->last = ngx_cpymem(b->last, r->args.data, r->args.len);
}
- h->last = ngx_cpymem(h->last, http_version, sizeof(http_version) - 1);
+ b->last = ngx_cpymem(b->last, http_version, sizeof(http_version) - 1);
/* the "Connection: close" header */
- h->last = ngx_cpymem(h->last, connection_close_header,
+ b->last = ngx_cpymem(b->last, connection_close_header,
sizeof(connection_close_header) - 1);
/* the "Host" header */
- h->last = ngx_cpymem(h->last, host_header, sizeof(host_header) - 1);
+ b->last = ngx_cpymem(b->last, host_header, sizeof(host_header) - 1);
if (p->lcf->preserve_host && r->headers_in.host) {
- h->last = ngx_cpymem(h->last, r->headers_in.host->value.data,
+ b->last = ngx_cpymem(b->last, r->headers_in.host->value.data,
r->headers_in.host_name_len);
if (!uc->default_port) {
- *(h->last++) = ':';
- h->last = ngx_cpymem(h->last, uc->port_text.data,
+ *(b->last++) = ':';
+ b->last = ngx_cpymem(b->last, uc->port_text.data,
uc->port_text.len);
}
} else {
- h->last = ngx_cpymem(h->last, uc->host_header.data,
+ b->last = ngx_cpymem(b->last, uc->host_header.data,
uc->host_header.len);
}
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
/* the "X-Real-IP" header */
if (p->lcf->set_x_real_ip) {
- h->last = ngx_cpymem(h->last, x_real_ip_header,
+ b->last = ngx_cpymem(b->last, x_real_ip_header,
sizeof(x_real_ip_header) - 1);
- h->last = ngx_cpymem(h->last, r->connection->addr_text.data,
+ b->last = ngx_cpymem(b->last, r->connection->addr_text.data,
r->connection->addr_text.len);
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
}
@@ -249,23 +251,23 @@
if (p->lcf->add_x_forwarded_for) {
if (r->headers_in.x_forwarded_for) {
- h->last = ngx_cpymem(h->last, x_forwarded_for_header,
+ b->last = ngx_cpymem(b->last, x_forwarded_for_header,
sizeof(x_forwarded_for_header) - 1);
- h->last = ngx_cpymem(h->last,
+ b->last = ngx_cpymem(b->last,
r->headers_in.x_forwarded_for->value.data,
r->headers_in.x_forwarded_for->value.len);
- *(h->last++) = ','; *(h->last++) = ' ';
+ *(b->last++) = ','; *(b->last++) = ' ';
} else {
- h->last = ngx_cpymem(h->last, x_forwarded_for_header,
+ b->last = ngx_cpymem(b->last, x_forwarded_for_header,
sizeof(x_forwarded_for_header) - 1);
}
- h->last = ngx_cpymem(h->last, r->connection->addr_text.data,
+ b->last = ngx_cpymem(b->last, r->connection->addr_text.data,
r->connection->addr_text.len);
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
}
@@ -289,14 +291,14 @@
continue;
}
- h->last = ngx_cpymem(h->last, header[i].key.data, header[i].key.len);
+ b->last = ngx_cpymem(b->last, header[i].key.data, header[i].key.len);
- *(h->last++) = ':'; *(h->last++) = ' ';
+ *(b->last++) = ':'; *(b->last++) = ' ';
- h->last = ngx_cpymem(h->last, header[i].value.data,
+ b->last = ngx_cpymem(b->last, header[i].value.data,
header[i].value.len);
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http proxy header: \"%s: %s\"",
@@ -304,12 +306,12 @@
}
/* add "\r\n" at the header end */
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
#if (NGX_DEBUG)
- *(h->last) = '\0';
+ *(b->last) = '\0';
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http proxy header:\n\"%s\"", h->pos);
+ "http proxy header:\n\"%s\"", b->pos);
#endif
return chain;
@@ -389,7 +391,7 @@
output->sendfile = r->sendfile;
output->pool = r->pool;
output->bufs.num = 1;
- output->tag = (ngx_hunk_tag_t) &ngx_http_proxy_module;
+ output->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
output->output_filter = (ngx_output_chain_filter_pt) ngx_chain_writer;
if (!(writer = ngx_palloc(r->pool, sizeof(ngx_chain_writer_ctx_t)))) {
@@ -420,15 +422,15 @@
/* reinit the request chain */
for (cl = p->request->request_body->bufs; cl; cl = cl->next) {
- cl->hunk->pos = cl->hunk->start;
- cl->hunk->file_pos = 0;
+ cl->buf->pos = cl->buf->start;
+ cl->buf->file_pos = 0;
}
/* reinit the ngx_output_chain() context */
output = p->upstream->output_chain_ctx;
- output->hunk = NULL;
+ output->buf = NULL;
output->in = NULL;
output->free = NULL;
output->busy = NULL;
@@ -614,9 +616,9 @@
return;
}
- output->free->hunk = r->request_body->buf;
- output->free->next = NULL;
- output->hunks = 1;
+ output->free->buf = r->request_body->buf;
+ output->free->buf = NULL;
+ output->allocated = 1;
r->request_body->buf->pos = r->request_body->buf->start;
}
@@ -793,13 +795,13 @@
}
if (p->header_in == NULL) {
- p->header_in = ngx_create_temp_hunk(p->request->pool,
- p->lcf->header_buffer_size);
+ p->header_in = ngx_create_temp_buf(p->request->pool,
+ p->lcf->header_buffer_size);
if (p->header_in == NULL) {
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
}
- p->header_in->tag = (ngx_hunk_tag_t) &ngx_http_proxy_module;
+ p->header_in->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
if (p->cache) {
p->header_in->pos += p->cache->ctx.header_size;
@@ -1176,7 +1178,7 @@
ep->output_filter = (ngx_event_pipe_output_filter_pt)
ngx_http_output_filter;
ep->output_ctx = r;
- ep->tag = (ngx_hunk_tag_t) &ngx_http_proxy_module;
+ ep->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
ep->bufs = p->lcf->bufs;
ep->busy_size = p->lcf->busy_buffers_size;
ep->upstream = p->upstream->peer.connection;
@@ -1206,25 +1208,24 @@
ep->max_temp_file_size = p->lcf->max_temp_file_size;
ep->temp_file_write_size = p->lcf->temp_file_write_size;
- ep->preread_hunks = ngx_alloc_chain_link(r->pool);
- if (ep->preread_hunks == NULL) {
+ if (!(ep->preread_bufs = ngx_alloc_chain_link(r->pool))) {
ngx_http_proxy_finalize_request(p, 0);
return;
}
- ep->preread_hunks->hunk = p->header_in;
- ep->preread_hunks->next = NULL;
+ ep->preread_bufs->buf = p->header_in;
+ ep->preread_bufs->next = NULL;
ep->preread_size = p->header_in->last - p->header_in->pos;
if (p->cachable) {
- ep->hunk_to_file = ngx_calloc_hunk(r->pool);
- if (ep->hunk_to_file == NULL) {
+ ep->buf_to_file = ngx_calloc_buf(r->pool);
+ if (ep->buf_to_file == NULL) {
ngx_http_proxy_finalize_request(p, 0);
return;
}
- ep->hunk_to_file->pos = p->header_in->start;
- ep->hunk_to_file->last = p->header_in->pos;
- ep->hunk_to_file->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
+ ep->buf_to_file->pos = p->header_in->start;
+ ep->buf_to_file->last = p->header_in->pos;
+ ep->buf_to_file->temporary = 1;
}
if (ngx_event_flags & NGX_USE_AIO_EVENT) {
@@ -1232,7 +1233,7 @@
ep->single_buf = 1;
}
- /* TODO: ep->free_bufs = 0 if use ngx_create_chain_of_hunks() */
+ /* TODO: ep->free_bufs = 0 if use ngx_create_chain_of_bufs() */
ep->free_bufs = 1;
/*
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index d7b4d12..bb71854 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -62,7 +62,7 @@
int ngx_http_parse_request_line(ngx_http_request_t *r);
int ngx_http_parse_complex_uri(ngx_http_request_t *r);
-int ngx_http_parse_header_line(ngx_http_request_t *r, ngx_hunk_t *h);
+int ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
int ngx_http_find_server_conf(ngx_http_request_t *r);
void ngx_http_handler(ngx_http_request_t *r);
diff --git a/src/http/ngx_http_cache.h b/src/http/ngx_http_cache.h
index 823f74d..25bf678 100644
--- a/src/http/ngx_http_cache.h
+++ b/src/http/ngx_http_cache.h
@@ -76,7 +76,7 @@
uint32_t crc;
u_char md5[16];
ngx_path_t *path;
- ngx_hunk_t *buf;
+ ngx_buf_t *buf;
time_t expires;
time_t last_modified;
time_t date;
diff --git a/src/http/ngx_http_copy_filter.c b/src/http/ngx_http_copy_filter.c
index 62485ed..96da0a5 100644
--- a/src/http/ngx_http_copy_filter.c
+++ b/src/http/ngx_http_copy_filter.c
@@ -80,7 +80,7 @@
ctx->pool = r->pool;
ctx->bufs = conf->bufs;
- ctx->tag = (ngx_hunk_tag_t) &ngx_http_copy_filter_module;
+ ctx->tag = (ngx_buf_tag_t) &ngx_http_copy_filter_module;
ctx->output_filter = (ngx_output_chain_filter_pt) ngx_http_next_filter;
ctx->filter_ctx = r;
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index e3bc734..eb55a69 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -95,7 +95,7 @@
u_char *p;
size_t len;
ngx_uint_t status, i;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t *ln;
ngx_table_elt_t *header;
@@ -215,39 +215,39 @@
len += header[i].key.len + 2 + header[i].value.len + 2;
}
- if (!(h = ngx_create_temp_hunk(r->pool, len))) {
+ if (!(b = ngx_create_temp_buf(r->pool, len))) {
return NGX_ERROR;
}
/* "HTTP/1.x " */
- h->last = ngx_cpymem(h->last, "HTTP/1.1 ", sizeof("HTTP/1.x ") - 1);
+ b->last = ngx_cpymem(b->last, "HTTP/1.1 ", sizeof("HTTP/1.x ") - 1);
/* status line */
if (r->headers_out.status_line.len) {
- h->last = ngx_cpymem(h->last, r->headers_out.status_line.data,
+ b->last = ngx_cpymem(b->last, r->headers_out.status_line.data,
r->headers_out.status_line.len);
} else {
- h->last = ngx_cpymem(h->last, http_codes[status].data,
+ b->last = ngx_cpymem(b->last, http_codes[status].data,
http_codes[status].len);
}
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
if (!(r->headers_out.server && r->headers_out.server->key.len)) {
- h->last = ngx_cpymem(h->last, server_string, sizeof(server_string) - 1);
+ b->last = ngx_cpymem(b->last, server_string, sizeof(server_string) - 1);
}
if (!(r->headers_out.date && r->headers_out.date->key.len)) {
- h->last = ngx_cpymem(h->last, "Date: ", sizeof("Date: ") - 1);
- h->last = ngx_cpymem(h->last, ngx_cached_http_time.data,
+ b->last = ngx_cpymem(b->last, "Date: ", sizeof("Date: ") - 1);
+ b->last = ngx_cpymem(b->last, ngx_cached_http_time.data,
ngx_cached_http_time.len);
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
}
if (r->headers_out.content_length == NULL) {
if (r->headers_out.content_length_n >= 0) {
- h->last += ngx_snprintf((char *) h->last,
+ b->last += ngx_snprintf((char *) b->last,
sizeof("Content-Length: ") + NGX_OFF_T_LEN + 2,
"Content-Length: " OFF_T_FMT CRLF,
r->headers_out.content_length_n);
@@ -255,69 +255,69 @@
}
if (r->headers_out.content_type && r->headers_out.content_type->value.len) {
- h->last = ngx_cpymem(h->last, "Content-Type: ",
+ b->last = ngx_cpymem(b->last, "Content-Type: ",
sizeof("Content-Type: ") - 1);
- p = h->last;
- h->last = ngx_cpymem(h->last, r->headers_out.content_type->value.data,
+ p = b->last;
+ b->last = ngx_cpymem(b->last, r->headers_out.content_type->value.data,
r->headers_out.content_type->value.len);
if (r->headers_out.charset.len) {
- h->last = ngx_cpymem(h->last, "; charset=",
+ b->last = ngx_cpymem(b->last, "; charset=",
sizeof("; charset=") - 1);
- h->last = ngx_cpymem(h->last, r->headers_out.charset.data,
+ b->last = ngx_cpymem(b->last, r->headers_out.charset.data,
r->headers_out.charset.len);
- r->headers_out.content_type->value.len = h->last - p;
+ r->headers_out.content_type->value.len = b->last - p;
r->headers_out.content_type->value.data = p;
}
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
}
if (r->headers_out.location
&& r->headers_out.location->value.len
&& r->headers_out.location->value.data[0] == '/')
{
- p = h->last + sizeof("Location: ") - 1;
- h->last = ngx_cpymem(h->last, "Location: http://",
+ p = b->last + sizeof("Location: ") - 1;
+ b->last = ngx_cpymem(b->last, "Location: http://",
sizeof("Location: http://") - 1);
- h->last = ngx_cpymem(h->last, r->server_name->data,
+ b->last = ngx_cpymem(b->last, r->server_name->data,
r->server_name->len);
if (r->port != 80) {
- h->last = ngx_cpymem(h->last, r->port_name->data,
+ b->last = ngx_cpymem(b->last, r->port_name->data,
r->port_name->len);
}
- h->last = ngx_cpymem(h->last, r->headers_out.location->value.data,
+ b->last = ngx_cpymem(b->last, r->headers_out.location->value.data,
r->headers_out.location->value.len);
- r->headers_out.location->value.len = h->last - p;
+ r->headers_out.location->value.len = b->last - p;
r->headers_out.location->value.data = p;
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
}
if (!(r->headers_out.last_modified && r->headers_out.last_modified->key.len)
&& r->headers_out.last_modified_time != -1)
{
- h->last = ngx_cpymem(h->last, "Last-Modified: ",
+ b->last = ngx_cpymem(b->last, "Last-Modified: ",
sizeof("Last-Modified: ") - 1);
- h->last += ngx_http_time(h->last, r->headers_out.last_modified_time);
+ b->last += ngx_http_time(b->last, r->headers_out.last_modified_time);
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
}
if (r->chunked) {
- h->last = ngx_cpymem(h->last, "Transfer-Encoding: chunked" CRLF,
+ b->last = ngx_cpymem(b->last, "Transfer-Encoding: chunked" CRLF,
sizeof("Transfer-Encoding: chunked" CRLF) - 1);
}
if (r->keepalive) {
- h->last = ngx_cpymem(h->last, "Connection: keep-alive" CRLF,
+ b->last = ngx_cpymem(b->last, "Connection: keep-alive" CRLF,
sizeof("Connection: keep-alive" CRLF) - 1);
} else {
- h->last = ngx_cpymem(h->last, "Connection: close" CRLF,
+ b->last = ngx_cpymem(b->last, "Connection: close" CRLF,
sizeof("Connection: close" CRLF) - 1);
}
@@ -326,33 +326,33 @@
continue;
}
- h->last = ngx_cpymem(h->last, header[i].key.data, header[i].key.len);
- *(h->last++) = ':' ; *(h->last++) = ' ' ;
+ b->last = ngx_cpymem(b->last, header[i].key.data, header[i].key.len);
+ *(b->last++) = ':' ; *(b->last++) = ' ' ;
- h->last = ngx_cpymem(h->last, header[i].value.data,
+ b->last = ngx_cpymem(b->last, header[i].value.data,
header[i].value.len);
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
}
#if (NGX_DEBUG)
- *(h->last) = '\0';
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s\n", h->pos);
+ *(b->last) = '\0';
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s\n", b->pos);
#endif
/* the end of HTTP header */
- *(h->last++) = CR; *(h->last++) = LF;
+ *(b->last++) = CR; *(b->last++) = LF;
- r->header_size = h->last - h->pos;
+ r->header_size = b->last - b->pos;
if (r->header_only) {
- h->type |= NGX_HUNK_LAST;
+ b->last_buf = 1;
}
if (!(ln = ngx_alloc_chain_link(r->pool))) {
return NGX_ERROR;
}
- ln->hunk = h;
+ ln->buf = b;
ln->next = NULL;
return ngx_http_write_filter(r, ln);
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 381ee57..76fbb80 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -438,7 +438,7 @@
}
-ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_hunk_t *h)
+ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b)
{
u_char c, ch, *p;
enum {
@@ -455,9 +455,9 @@
} state;
state = r->state;
- p = h->pos;
+ p = b->pos;
- while (p < h->last && state < sw_done) {
+ while (p < b->last && state < sw_done) {
ch = *p++;
switch (state) {
@@ -623,7 +623,7 @@
}
}
- h->pos = p;
+ b->pos = p;
if (state == sw_done) {
r->state = sw_start;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 25cc295..9487d06 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -236,8 +236,8 @@
}
if (c->buffer == NULL) {
- c->buffer = ngx_create_temp_hunk(c->pool,
- cscf->client_header_buffer_size);
+ c->buffer = ngx_create_temp_buf(c->pool,
+ cscf->client_header_buffer_size);
if (c->buffer == NULL) {
ngx_http_close_connection(c);
return;
@@ -1233,7 +1233,7 @@
static void ngx_http_set_keepalive(ngx_http_request_t *r)
{
int len;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_event_t *rev, *wev;
ngx_connection_t *c;
ngx_http_log_ctx_t *ctx;
@@ -1257,12 +1257,12 @@
return;
}
- h = c->buffer;
+ b = c->buffer;
wev = c->write;
wev->event_handler = ngx_http_empty_handler;
- if (h->pos < h->last) {
+ if (b->pos < b->last) {
/*
* The pipelined request.
@@ -1277,10 +1277,10 @@
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
if (!cscf->large_client_header) {
- len = h->last - h->pos;
- ngx_memcpy(h->start, h->pos, len);
- h->pos = h->start;
- h->last = h->start + len;
+ len = b->last - b->pos;
+ ngx_memcpy(b->start, b->pos, len);
+ b->pos = b->start;
+ b->last = b->start + len;
}
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request");
@@ -1293,7 +1293,7 @@
c->pipeline = 0;
- h->pos = h->last = h->start;
+ b->pos = b->last = b->start;
rev->event_handler = ngx_http_keepalive_handler;
if (wev->active) {
@@ -1523,12 +1523,15 @@
int ngx_http_send_last(ngx_http_request_t *r)
{
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t out;
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_LAST;
- out.hunk = h;
+ if (!(b = ngx_calloc_buf(r->pool))) {
+ return NGX_ERROR;
+ }
+
+ b->last_buf = 1;
+ out.buf = b;
out.next = NULL;
return ngx_http_output_filter(r, &out);
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 8013ef8..77cabb5 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -176,7 +176,7 @@
typedef struct {
ngx_temp_file_t *temp_file;
ngx_chain_t *bufs;
- ngx_hunk_t *buf;
+ ngx_buf_t *buf;
size_t rest;
void (*handler) (void *data);
void *data;
@@ -216,7 +216,7 @@
ngx_file_t file;
ngx_pool_t *pool;
- ngx_hunk_t *header_in;
+ ngx_buf_t *header_in;
ngx_http_headers_in_t headers_in;
ngx_http_headers_out_t headers_out;
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index c4aada5..a1e2c5a 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -12,7 +12,7 @@
ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r)
{
ssize_t size;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t *cl;
ngx_http_core_loc_conf_t *clcf;
@@ -22,14 +22,14 @@
/* there is the pre-read part of the request body */
- ngx_test_null(h, ngx_calloc_hunk(r->pool),
+ ngx_test_null(b, ngx_calloc_buf(r->pool),
NGX_HTTP_INTERNAL_SERVER_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
- h->start = h->pos = r->header_in->pos;
- h->end = h->last = r->header_in->last;
+ b->temporary = 1;
+ b->start = b->pos = r->header_in->pos;
+ b->end = b->last = r->header_in->last;
- ngx_alloc_link_and_set_hunk(r->request_body->bufs, h, r->pool,
+ ngx_alloc_link_and_set_buf(r->request_body->bufs, b, r->pool,
NGX_HTTP_INTERNAL_SERVER_ERROR);
if (size >= r->headers_in.content_length_n) {
@@ -61,11 +61,11 @@
size = clcf->client_body_buffer_size;
}
- ngx_test_null(r->request_body->buf, ngx_create_temp_hunk(r->pool, size),
+ ngx_test_null(r->request_body->buf, ngx_create_temp_buf(r->pool, size),
NGX_HTTP_INTERNAL_SERVER_ERROR);
- ngx_alloc_link_and_set_hunk(cl, r->request_body->buf, r->pool,
- NGX_HTTP_INTERNAL_SERVER_ERROR);
+ ngx_alloc_link_and_set_buf(cl, r->request_body->buf, r->pool,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
if (r->request_body->bufs) {
r->request_body->bufs->next = cl;
@@ -107,7 +107,7 @@
{
size_t size;
ssize_t n;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_connection_t *c;
ngx_http_core_loc_conf_t *clcf;
@@ -199,21 +199,20 @@
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- h = ngx_calloc_hunk(r->pool);
- if (h == NULL) {
+ if (!(b = ngx_calloc_buf(r->pool))) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- h->type = NGX_HUNK_FILE;
- h->file_pos = 0;
- h->file_last = r->request_body->temp_file->file.offset;
- h->file = &r->request_body->temp_file->file;
+ b->in_file = 1;
+ b->file_pos = 0;
+ b->file_last = r->request_body->temp_file->file.offset;
+ b->file = &r->request_body->temp_file->file;
if (r->request_body->bufs->next) {
- r->request_body->bufs->next->hunk = h;
+ r->request_body->bufs->next->buf = b;
} else {
- r->request_body->bufs->hunk = h;
+ r->request_body->bufs->buf = b;
}
}
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 4896346..2e26640 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -181,7 +181,7 @@
{
ngx_int_t rc;
ngx_uint_t err, i;
- ngx_hunk_t *h;
+ ngx_buf_t *b;
ngx_chain_t *out, **ll, *cl;
ngx_http_err_page_t *err_page;
ngx_http_core_loc_conf_t *clcf;
@@ -293,25 +293,25 @@
out = NULL;
ll = NULL;
- if (!(h = ngx_calloc_hunk(r->pool))) {
+ if (!(b = ngx_calloc_buf(r->pool))) {
return NGX_ERROR;
}
- h->type = NGX_HUNK_MEMORY|NGX_HUNK_IN_MEMORY;
- h->pos = error_pages[err].data;
- h->last = error_pages[err].data + error_pages[err].len;
+ b->memory = 1;
+ b->pos = error_pages[err].data;
+ b->last = error_pages[err].data + error_pages[err].len;
- ngx_alloc_link_and_set_hunk(cl, h, r->pool, NGX_ERROR);
+ ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR);
ngx_chain_add_link(out, ll, cl);
- if (!(h = ngx_calloc_hunk(r->pool))) {
+ if (!(b = ngx_calloc_buf(r->pool))) {
return NGX_ERROR;
}
- h->type = NGX_HUNK_MEMORY|NGX_HUNK_IN_MEMORY;
- h->pos = error_tail;
- h->last = error_tail + sizeof(error_tail) - 1;
+ b->memory = 1;
+ b->pos = error_tail;
+ b->last = error_tail + sizeof(error_tail) - 1;
- ngx_alloc_link_and_set_hunk(cl, h, r->pool, NGX_ERROR);
+ ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR);
ngx_chain_add_link(out, ll, cl);
if (clcf->msie_padding
@@ -319,18 +319,18 @@
&& error >= NGX_HTTP_BAD_REQUEST
&& error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
{
- if (!(h = ngx_calloc_hunk(r->pool))) {
+ if (!(b = ngx_calloc_buf(r->pool))) {
return NGX_ERROR;
}
- h->type = NGX_HUNK_MEMORY|NGX_HUNK_IN_MEMORY;
- h->pos = msie_stub;
- h->last = msie_stub + sizeof(msie_stub) - 1;
+ b->memory = 1;
+ b->pos = msie_stub;
+ b->last = msie_stub + sizeof(msie_stub) - 1;
- ngx_alloc_link_and_set_hunk(cl, h, r->pool, NGX_ERROR);
+ ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR);
ngx_chain_add_link(out, ll, cl);
}
- h->type |= NGX_HUNK_LAST;
+ b->last_buf = 1;
return ngx_http_output_filter(r, out);
}
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index 1728c64..e23649e 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -92,13 +92,13 @@
for (cl = ctx->out; cl; cl = cl->next) {
ll = &cl->next;
- size += ngx_hunk_size(cl->hunk);
+ size += ngx_buf_size(cl->buf);
- if (cl->hunk->type & (NGX_HUNK_FLUSH|NGX_HUNK_RECYCLED)) {
+ if (cl->buf->flush || cl->buf->recycled) {
flush = size;
}
- if (cl->hunk->type & NGX_HUNK_LAST) {
+ if (cl->buf->last_buf) {
last = 1;
}
}
@@ -106,17 +106,17 @@
/* add the new chain to the existent one */
for (ln = in; ln; ln = ln->next) {
- ngx_alloc_link_and_set_hunk(cl, ln->hunk, r->pool, NGX_ERROR);
+ ngx_alloc_link_and_set_buf(cl, ln->buf, r->pool, NGX_ERROR);
*ll = cl;
ll = &cl->next;
- size += ngx_hunk_size(cl->hunk);
+ size += ngx_buf_size(cl->buf);
- if (cl->hunk->type & (NGX_HUNK_FLUSH|NGX_HUNK_RECYCLED)) {
+ if (cl->buf->flush || cl->buf->recycled) {
flush = size;
}
- if (cl->hunk->type & NGX_HUNK_LAST) {
+ if (cl->buf->last_buf) {
last = 1;
}
}