diff src/http/modules/ngx_http_static_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/modules/ngx_http_static_handler.c@64d9afb209da
children 9b8c906f6e63
line wrap: on
line diff
copy from src/http/modules/ngx_http_static_handler.c
copy to src/http/modules/ngx_http_static_module.c
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -75,10 +75,13 @@ static ngx_int_t ngx_http_static_handler
     ngx_buf_t                   *b;
     ngx_chain_t                  out;
     ngx_file_info_t              fi;
-    ngx_http_cleanup_t          *file_cleanup, *redirect_cleanup;
+    ngx_http_cleanup_t          *file_cleanup;
+#if (NGX_HTTP_CACHE)
+    ngx_http_cleanup_t          *redirect_cleanup;
+#endif
     ngx_http_core_loc_conf_t    *clcf;
+#if (NGX_HTTP_CACHE)
     ngx_http_static_loc_conf_t  *slcf;
-#if (NGX_HTTP_CACHE)
     uint32_t                     file_crc, redirect_crc;
     ngx_http_cache_t            *file, *redirect;
 #endif
@@ -176,14 +179,18 @@ static ngx_int_t ngx_http_static_handler
 
     /* allocate cleanups */
 
-    if (!(file_cleanup = ngx_push_array(&r->cleanup))) {
+    file_cleanup = ngx_array_push(&r->cleanup);
+    if (file_cleanup == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
     file_cleanup->valid = 0;
 
+#if (NGX_HTTP_CACHE)
+
     slcf = ngx_http_get_module_loc_conf(r, ngx_http_static_module);
     if (slcf->redirect_cache) {
-        if (!(redirect_cleanup = ngx_push_array(&r->cleanup))) {
+        redirect_cleanup = ngx_array_push(&r->cleanup);
+        if (redirect_cleanup == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
         redirect_cleanup->valid = 0;
@@ -192,8 +199,6 @@ static ngx_int_t ngx_http_static_handler
         redirect_cleanup = NULL;
     }
 
-#if (NGX_HTTP_CACHE)
-
     /* look up an open files cache */
 
     if (clcf->open_files) {
@@ -232,9 +237,9 @@ static ngx_int_t ngx_http_static_handler
              * should keep more popular redirects in cache.
              */
 
-            if (!(r->headers_out.location =
-                   ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
-            {
+            r->headers_out.location = ngx_http_add_header(&r->headers_out,
+                                                          ngx_http_headers_out);
+            if (r->headers_out.location == NULL) {
                 return NGX_HTTP_INTERNAL_SERVER_ERROR;
             }
 
@@ -283,9 +288,9 @@ static ngx_int_t ngx_http_static_handler
             ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
                            "HTTP DIR: \"%s\"", name.data);
 
-            if (!(r->headers_out.location =
-                   ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
-            {
+            r->headers_out.location = ngx_http_add_header(&r->headers_out,
+                                                          ngx_http_headers_out);
+            if (r->headers_out.location == NULL) {
                 return NGX_HTTP_INTERNAL_SERVER_ERROR;
             }
 
@@ -506,11 +511,13 @@ static ngx_int_t ngx_http_static_handler
     if (!r->header_only) {
         /* we need to allocate all before the header would be sent */
 
-        if (!(b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)))) {
+        b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+        if (b == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
 
-        if (!(b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)))) {
+        b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));
+        if (b->file == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
 
@@ -547,7 +554,8 @@ static void *ngx_http_static_create_loc_
 {
     ngx_http_static_loc_conf_t  *conf;
 
-    if (!(conf = ngx_palloc(cf->pool, sizeof(ngx_http_static_loc_conf_t)))) {
+    conf = ngx_palloc(cf->pool, sizeof(ngx_http_static_loc_conf_t));
+    if (conf == NULL) {
         return NGX_CONF_ERROR;
     }
 
@@ -578,7 +586,7 @@ static ngx_int_t ngx_http_static_init(ng
 
     cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
     
-    h = ngx_push_array(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
+    h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
     if (h == NULL) {
         return NGX_ERROR;
     }