diff src/http/ngx_http_write_filter_module.c @ 501:d4ea69372b94 release-0.1.25

nginx-0.1.25-RELEASE import *) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author Igor Sysoev <igor@sysoev.ru>
date Sat, 19 Mar 2005 12:38:37 +0000
parents src/http/ngx_http_write_filter.c@64d9afb209da
children cd3117ad9aab
line wrap: on
line diff
copy from src/http/ngx_http_write_filter.c
copy to src/http/ngx_http_write_filter_module.c
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter_module.c
@@ -42,7 +42,8 @@ ngx_module_t  ngx_http_write_filter_modu
 };
 
 
-ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
+ngx_int_t
+ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
 {
     off_t                         size, sent;
     ngx_uint_t                    last, flush;
@@ -55,8 +56,13 @@ ngx_int_t ngx_http_write_filter(ngx_http
                                   ngx_http_write_filter_module);
 
     if (ctx == NULL) {
-        ngx_http_create_ctx(r, ctx, ngx_http_write_filter_module,
-                            sizeof(ngx_http_write_filter_ctx_t), NGX_ERROR);
+
+        ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_write_filter_ctx_t));
+        if (ctx == NULL) {
+            return NGX_ERROR;
+        }
+
+        ngx_http_set_ctx(r, ctx, ngx_http_write_filter_module);
     }
 
     size = 0;
@@ -112,7 +118,8 @@ ngx_int_t ngx_http_write_filter(ngx_http
     /* add the new chain to the existent one */
 
     for (ln = in; ln; ln = ln->next) {
-        if (!(cl = ngx_alloc_chain_link(r->pool))) {
+        cl = ngx_alloc_chain_link(r->pool);
+        if (cl == NULL) {
             return NGX_ERROR;
         }
 
@@ -190,7 +197,11 @@ ngx_int_t ngx_http_write_filter(ngx_http
         }
 
         if (flush) {
-            while ((ctx->out = ctx->out->next)) { /* void */ }
+            do {
+                ctx->out = ctx->out->next;
+            }
+            while (ctx->out);
+
             return NGX_OK;
         }
 
@@ -230,7 +241,8 @@ ngx_int_t ngx_http_write_filter(ngx_http
 }
 
 
-static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_http_write_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_top_body_filter = ngx_http_write_filter;