diff src/http/ngx_http_copy_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_copy_filter.c@23fb87bddda1
children 9b8c906f6e63
line wrap: on
line diff
copy from src/http/ngx_http_copy_filter.c
copy to src/http/ngx_http_copy_filter_module.c
--- a/src/http/ngx_http_copy_filter.c
+++ b/src/http/ngx_http_copy_filter_module.c
@@ -16,20 +16,20 @@ typedef struct {
 
 static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf);
 static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
-                                             void *parent, void *child);
+    void *parent, void *child);
 static ngx_int_t ngx_http_copy_filter_init(ngx_cycle_t *cycle);
 
 
 static ngx_command_t  ngx_http_copy_filter_commands[] = {
 
-    {ngx_string("output_buffers"),
-     NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
-     ngx_conf_set_bufs_slot,
-     NGX_HTTP_LOC_CONF_OFFSET,
-     offsetof(ngx_http_copy_filter_conf_t, bufs),
-     NULL},
+    { ngx_string("output_buffers"),
+      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
+      ngx_conf_set_bufs_slot,
+      NGX_HTTP_LOC_CONF_OFFSET,
+      offsetof(ngx_http_copy_filter_conf_t, bufs),
+      NULL },
 
-    ngx_null_command
+      ngx_null_command
 };
 
 
@@ -60,7 +60,8 @@ ngx_module_t  ngx_http_copy_filter_modul
 static ngx_http_output_body_filter_pt    ngx_http_next_filter;
 
 
-ngx_int_t ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
+static ngx_int_t
+ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
 {
     ngx_output_chain_ctx_t       *ctx;
     ngx_http_copy_filter_conf_t  *conf;
@@ -76,8 +77,12 @@ ngx_int_t ngx_http_copy_filter(ngx_http_
         conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
                                             ngx_http_copy_filter_module);
 
-        ngx_http_create_ctx(r, ctx, ngx_http_copy_filter_module,
-                            sizeof(ngx_output_chain_ctx_t), NGX_ERROR);
+        ctx = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t));
+        if (ctx == NULL) {
+            return NGX_ERROR;
+        }
+
+        ngx_http_set_ctx(r, ctx, ngx_http_copy_filter_module);
 
         ctx->sendfile = r->connection->sendfile;
         ctx->need_in_memory = r->filter_need_in_memory;
@@ -96,13 +101,15 @@ ngx_int_t ngx_http_copy_filter(ngx_http_
 }
 
 
-static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf)
+static void *
+ngx_http_copy_filter_create_conf(ngx_conf_t *cf)
 {
     ngx_http_copy_filter_conf_t *conf;
 
-    ngx_test_null(conf,
-                  ngx_palloc(cf->pool, sizeof(ngx_http_copy_filter_conf_t)),
-                  NULL);
+    conf = ngx_palloc(cf->pool, sizeof(ngx_http_copy_filter_conf_t));
+    if (conf == NULL) {
+        return NULL;
+    }
 
     conf->bufs.num = 0;
 
@@ -110,8 +117,8 @@ static void *ngx_http_copy_filter_create
 }
 
 
-static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
-                                             void *parent, void *child)
+static char *
+ngx_http_copy_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child)
 {
     ngx_http_copy_filter_conf_t *prev = parent;
     ngx_http_copy_filter_conf_t *conf = child;
@@ -122,7 +129,8 @@ static char *ngx_http_copy_filter_merge_
 }
 
 
-static ngx_int_t ngx_http_copy_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_http_copy_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_next_filter = ngx_http_top_body_filter;
     ngx_http_top_body_filter = ngx_http_copy_filter;