nginx-0.0.11-2004-09-19-22:27:00 import
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index f177076..8efd369 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -67,6 +67,7 @@
"zero size buf");
ctx->in = ctx->in->next;
+
continue;
}
@@ -146,6 +147,7 @@
if (out) {
break;
}
+
return rc;
}
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index b170df8..edc643a 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -51,9 +51,11 @@
unsigned flush:4;
unsigned redo:1;
- unsigned pass:1;
unsigned done:1;
+#if 0
+ unsigned pass:1;
unsigned blocked:1;
+#endif
size_t zin;
size_t zout;
@@ -445,8 +447,10 @@
ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9));
- ngx_test_null(ctx->preallocated, ngx_palloc(r->pool, ctx->allocated),
- NGX_ERROR);
+ if (!(ctx->preallocated = ngx_palloc(r->pool, ctx->allocated))) {
+ return NGX_ERROR;
+ }
+
ctx->free_mem = ctx->preallocated;
ctx->zstream.zalloc = ngx_http_gzip_filter_alloc;
@@ -462,7 +466,9 @@
return ngx_http_gzip_error(ctx);
}
- ngx_test_null(b, ngx_calloc_buf(r->pool), ngx_http_gzip_error(ctx));
+ if (!(b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)))) {
+ return ngx_http_gzip_error(ctx);
+ }
b->memory = 1;
b->pos = gzheader;
@@ -488,7 +494,7 @@
for ( ;; ) {
- /* is there a data to gzip ? */
+ /* does zlib need a new data ? */
if (ctx->zstream.avail_in == 0
&& ctx->flush == Z_NO_FLUSH
@@ -519,6 +525,7 @@
ctx->done = 1;
return NGX_ERROR;
}
+ /**/
if (ctx->in_buf->last_buf) {
ctx->flush = Z_FINISH;
@@ -538,28 +545,37 @@
}
}
+
/* is there a space for the gzipped data ? */
if (ctx->zstream.avail_out == 0) {
+
if (ctx->free) {
ctx->out_buf = ctx->free->buf;
ctx->free = ctx->free->next;
} 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 = ngx_create_temp_buf(r->pool,
+ conf->bufs.size);
+ if (ctx->out_buf == NULL) {
+ return ngx_http_gzip_error(ctx);
+ }
+
ctx->out_buf->tag = (ngx_buf_tag_t)
&ngx_http_gzip_filter_module;
ctx->out_buf->recycled = 1;
ctx->bufs++;
} else {
+#if 0
ctx->blocked = 1;
+#endif
break;
}
+#if 0
ctx->blocked = 0;
+#endif
ctx->zstream.next_out = ctx->out_buf->pos;
ctx->zstream.avail_out = conf->bufs.size;
}
@@ -571,6 +587,7 @@
ctx->flush, ctx->redo);
rc = deflate(&ctx->zstream, ctx->flush);
+
if (rc != Z_OK && rc != Z_STREAM_END) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"deflate() failed: %d, %d", ctx->flush, rc);
@@ -599,10 +616,14 @@
ctx->out_buf->last = ctx->zstream.next_out;
if (ctx->zstream.avail_out == 0) {
+
+ /* zlib wants to output some more gzipped data */
+
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;
continue;
@@ -611,6 +632,7 @@
ctx->redo = 0;
if (ctx->flush == Z_SYNC_FLUSH) {
+
ctx->out_buf->flush = 0;
ctx->flush = Z_NO_FLUSH;
@@ -618,7 +640,10 @@
ngx_http_gzip_error(ctx));
*ctx->last_out = cl;
ctx->last_out = &cl->next;
+
+#if 0
ctx->pass = 1;
+#endif
break;
}
@@ -629,6 +654,7 @@
ctx->zout = 10 + ctx->zstream.total_out + 8;
rc = deflateEnd(&ctx->zstream);
+
if (rc != Z_OK) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"deflateEnd() failed: %d", rc);
@@ -648,8 +674,9 @@
ctx->out_buf->last_buf = 1;
} else {
- ngx_test_null(b, ngx_create_temp_buf(r->pool, 8),
- ngx_http_gzip_error(ctx));
+ if (!(b = ngx_create_temp_buf(r->pool, 8))) {
+ return ngx_http_gzip_error(ctx);
+ }
b->last_buf = 1;
@@ -680,7 +707,9 @@
ctx->zstream.avail_out = 0;
ctx->done = 1;
+#if 0
ctx->pass = 1;
+#endif
break;
}
@@ -690,12 +719,19 @@
ngx_http_gzip_error(ctx));
*ctx->last_out = cl;
ctx->last_out = &cl->next;
+
+#if 0
ctx->pass = 1;
+#endif
break;
}
}
+#if 0
+
+ /* OLD CODE */
+
if (ctx->out) {
if (ctx->pass) {
ctx->pass = 0;
@@ -704,6 +740,11 @@
return last;
}
+ } else if (ctx->busy->buf && ngx_buf_size(ctx->busy->buf)) {
+ if (last != NGX_NONE) {
+ return last;
+ }
+
} else if (ctx->blocked) {
if (last != NGX_NONE) {
return last;
@@ -716,9 +757,27 @@
return last;
}
+#endif
+
+ /* NEW CODE */
+
+ if (last == NGX_AGAIN) {
+ return NGX_AGAIN;
+ }
+
+ if (ctx->out == NULL && ctx->busy == NULL) {
+ return NGX_OK;
+ }
+
+ /**/
last = ngx_http_next_body_filter(r, ctx->out);
+ /*
+ * we do not check NGX_AGAIN here because the downstream filters
+ * may free some buffers and zlib may compress some data into them
+ */
+
if (last == NGX_ERROR) {
return ngx_http_gzip_error(ctx);
}
@@ -873,22 +932,22 @@
{
ngx_http_gzip_conf_t *conf;
- ngx_test_null(conf,
- ngx_pcalloc(cf->pool, sizeof(ngx_http_gzip_conf_t)),
- NGX_CONF_ERROR);
+ if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_gzip_conf_t)))) {
+ return NGX_CONF_ERROR;
+ }
- /* set by ngx_pcalloc():
+ /*
+
+ set by ngx_pcalloc():
conf->bufs.num = 0;
conf->proxied = 0;
- */
-
+ */
conf->enable = NGX_CONF_UNSET;
conf->no_buffer = NGX_CONF_UNSET;
-
conf->http_version = NGX_CONF_UNSET_UINT;
conf->level = NGX_CONF_UNSET;
@@ -933,16 +992,14 @@
int wbits, wsize;
-
-ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "WBITS: %d", *np);
-
wbits = 15;
+
for (wsize = 32 * 1024; wsize > 256; wsize >>= 1) {
if (wsize == *np) {
*np = wbits;
-ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "WBITS: %d", *np);
- return NULL;
+
+ return NGX_CONF_OK;
}
wbits--;
@@ -958,16 +1015,14 @@
int memlevel, hsize;
-
-ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "MEMLEVEL: %d", *np);
-
memlevel = 9;
+
for (hsize = 128 * 1024; hsize > 256; hsize >>= 1) {
if (hsize == *np) {
*np = memlevel;
-ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "MEMLEVEL: %d", *np);
- return NULL;
+
+ return NGX_CONF_OK;
}
memlevel--;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 70f9955..bc21021 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1153,7 +1153,7 @@
if (!r->headers_in.msie && !r->headers_in.opera) {
- if (ngx_strstr(user_agent, "Gecko")) {
+ if (ngx_strstr(user_agent, "Gecko/")) {
r->headers_in.gecko = 1;
} else if (ngx_strstr(user_agent, "Konqueror")) {