diff src/http/ngx_http.c @ 396:349057ecf4d5 NGINX_0_7_10

nginx 0.7.10 *) Bugfix: in the "addition_types", "charset_types", "gzip_types", "ssi_types", "sub_filter_types", and "xslt_types" directives; the bugs had appeared in 0.7.9. *) Bugfix: of recursive error_page for 500 status code. *) Bugfix: now the ngx_http_realip_module set address not for whole keepalive connection, but for each request passed via the connection.
author Igor Sysoev <http://sysoev.ru>
date Wed, 13 Aug 2008 00:00:00 +0400
parents 05981f639d21
children a094317ba307
line wrap: on
line diff
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1761,43 +1761,60 @@ ngx_http_types_slot(ngx_conf_t *cf, ngx_
 
 char *
 ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys, ngx_hash_t *types_hash,
-    ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash, 
+    ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
     ngx_str_t *default_types)
 {
     ngx_hash_init_t  hash;
 
-    if (keys == NULL) {
+    if (keys) {
 
-        if (prev_keys) {
-            *types_hash = *prev_types_hash;
-            return NGX_CONF_OK;
+        hash.hash = types_hash;
+        hash.key = NULL;
+        hash.max_size = 2048;
+        hash.bucket_size = 64;
+        hash.name = "test_types_hash";
+        hash.pool = cf->pool;
+        hash.temp_pool = NULL;
+
+        if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) {
+            return NGX_CONF_ERROR;
         }
 
-        if (ngx_http_set_default_types(cf, &keys, default_types)
-            != NGX_CONF_OK)
-        {
+        return NGX_CONF_OK;
+    }
+
+    if (prev_types_hash->buckets == NULL) {
+
+        if (prev_keys == NULL) {
+
+	    if (ngx_http_set_default_types(cf, &prev_keys, default_types)
+                != NGX_OK)
+            {
+		return NGX_CONF_ERROR;
+	    }
+        }
+
+        hash.hash = prev_types_hash;
+        hash.key = NULL;
+        hash.max_size = 2048;
+        hash.bucket_size = 64;
+        hash.name = "test_types_hash";
+        hash.pool = cf->pool;
+        hash.temp_pool = NULL;
+
+        if (ngx_hash_init(&hash, prev_keys->elts, prev_keys->nelts) != NGX_OK) {
             return NGX_CONF_ERROR;
         }
     }
 
-    hash.hash = types_hash;
-    hash.key = NULL;
-    hash.max_size = 2048;
-    hash.bucket_size = 64;
-    hash.name = "test_types_hash";
-    hash.pool = cf->pool;
-    hash.temp_pool = NULL;
-
-    if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) {
-        return NGX_CONF_ERROR;
-    }
+    *types_hash = *prev_types_hash;
 
     return NGX_CONF_OK;
 
 }
 
 
-char *
+ngx_int_t
 ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
     ngx_str_t *default_type)
 {
@@ -1805,14 +1822,14 @@ ngx_http_set_default_types(ngx_conf_t *c
 
     *types = ngx_array_create(cf->temp_pool, 1, sizeof(ngx_hash_key_t));
     if (*types == NULL) {
-        return NGX_CONF_ERROR;
+        return NGX_ERROR;
     }
 
     while (default_type->len) {
 
         type = ngx_array_push(*types);
         if (type == NULL) {
-            return NGX_CONF_ERROR;
+            return NGX_ERROR;
         }
 
         type->key = *default_type;
@@ -1823,5 +1840,5 @@ ngx_http_set_default_types(ngx_conf_t *c
         default_type++;
     }
 
-    return NGX_CONF_OK;
+    return NGX_OK;
 }