changeset 614:bb20316269e4 NGINX_0_9_5

nginx 0.9.5 *) Change: now nginx uses a default listen backlog value -1 on Linux. Thanks to Andrei Nigmatulin. *) Feature: the "utf8" parameter of "geoip_country" and "geoip_city" directives. Thanks to Denis F. Latypoff. *) Bugfix: in a default "proxy_redirect" directive if "proxy_pass" directive has no URI part. Thanks to Maxim Dounin. *) Bugfix: an "error_page" directive did not work with nonstandard error codes; the bug had appeared in 0.8.53. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Mon, 21 Feb 2011 00:00:00 +0300
parents eaf85af608b8
children 02221dcea723
files CHANGES CHANGES.ru conf/mime.types src/core/nginx.h src/core/ngx_inet.c src/http/modules/ngx_http_geoip_module.c src/http/modules/ngx_http_proxy_module.c src/http/modules/perl/nginx.pm src/http/ngx_http_special_response.c src/os/unix/ngx_files.c src/os/unix/ngx_linux_config.h
diffstat 11 files changed, 107 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Fri Jan 21 00:00:00 2011 +0300
+++ b/CHANGES	Mon Feb 21 00:00:00 2011 +0300
@@ -1,4 +1,23 @@
 
+Changes with nginx 0.9.5                                         21 Feb 2011
+
+    *) Change: now nginx uses a default listen backlog value -1 on 
+       Linux.
+       Thanks to Andrei Nigmatulin.
+
+    *) Feature: the "utf8" parameter of "geoip_country" and "geoip_city" 
+       directives.
+       Thanks to Denis F. Latypoff.
+
+    *) Bugfix: in a default "proxy_redirect" directive if "proxy_pass" 
+       directive has no URI part.
+       Thanks to Maxim Dounin.
+
+    *) Bugfix: an "error_page" directive did not work with nonstandard 
+       error codes; the bug had appeared in 0.8.53.
+       Thanks to Maxim Dounin.
+
+
 Changes with nginx 0.9.4                                         21 Jan 2011
 
     *) Feature: the "server_name" directive supports the $hostname variable.
--- a/CHANGES.ru	Fri Jan 21 00:00:00 2011 +0300
+++ b/CHANGES.ru	Mon Feb 21 00:00:00 2011 +0300
@@ -1,4 +1,23 @@
 
+Изменения в nginx 0.9.5                                           21.02.2011
+
+    *) Изменение: теперь по умолчанию nginx использует значение -1 для 
+       listen backlog на Linux.
+       Спасибо Андрею Нигматулину.
+
+    *) Добавление: параметр utf8 в директивах geoip_country и 
+       geoip_city.
+       Спасибо Денису Латыпову.
+
+    *) Исправление: исправление в умолчательной директиве proxy_redirect, 
+       если в директиве proxy_pass не был описан URI.
+       Спасибо Максиму Дунину.
+
+    *) Исправление: директива error_page не работала с нестандартными 
+       кодами ошибок; ошибка появилась в 0.8.53.
+       Спасибо Максиму Дунину.
+
+
 Изменения в nginx 0.9.4                                           21.01.2011
 
     *) Добавление: директива server_name поддерживает переменную $hostname.
--- a/conf/mime.types	Fri Jan 21 00:00:00 2011 +0300
+++ b/conf/mime.types	Mon Feb 21 00:00:00 2011 +0300
@@ -32,7 +32,6 @@
     application/vnd.ms-excel              xls;
     application/vnd.ms-powerpoint         ppt;
     application/vnd.wap.wmlc              wmlc;
-    application/vnd.wap.xhtml+xml         xhtml;
     application/vnd.google-earth.kml+xml  kml;
     application/vnd.google-earth.kmz      kmz;
     application/x-7z-compressed           7z;
@@ -50,6 +49,7 @@
     application/x-tcl                     tcl tk;
     application/x-x509-ca-cert            der pem crt;
     application/x-xpinstall               xpi;
+    application/xhtml+xml                 xhtml;
     application/zip                       zip;
 
     application/octet-stream              bin exe dll;
--- a/src/core/nginx.h	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/core/nginx.h	Mon Feb 21 00:00:00 2011 +0300
@@ -8,8 +8,8 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define nginx_version         9004
-#define NGINX_VERSION      "0.9.4"
+#define nginx_version         9005
+#define NGINX_VERSION      "0.9.5"
 #define NGINX_VER          "nginx/" NGINX_VERSION
 
 #define NGINX_VAR          "NGINX"
--- a/src/core/ngx_inet.c	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/core/ngx_inet.c	Mon Feb 21 00:00:00 2011 +0300
@@ -943,7 +943,7 @@
 
         u->naddrs = i;
 
-        for (i = 0; h->h_addr_list[i] != NULL; i++) {
+        for (i = 0; i < u->naddrs; i++) {
 
             sin = ngx_pcalloc(pool, sizeof(struct sockaddr_in));
             if (sin == NULL) {
--- a/src/http/modules/ngx_http_geoip_module.c	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/http/modules/ngx_http_geoip_module.c	Mon Feb 21 00:00:00 2011 +0300
@@ -50,14 +50,14 @@
 static ngx_command_t  ngx_http_geoip_commands[] = {
 
     { ngx_string("geoip_country"),
-      NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+      NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE12,
       ngx_http_geoip_country,
       NGX_HTTP_MAIN_CONF_OFFSET,
       0,
       NULL },
 
     { ngx_string("geoip_city"),
-      NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+      NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE12,
       ngx_http_geoip_city,
       NGX_HTTP_MAIN_CONF_OFFSET,
       0,
@@ -446,6 +446,17 @@
         return NGX_CONF_ERROR;
     }
 
+    if (cf->args->nelts == 3) {
+        if (ngx_strcmp(value[2].data, "utf8") == 0) {
+            GeoIP_set_charset (gcf->country, GEOIP_CHARSET_UTF8);
+
+        } else {
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "invalid parameter \"%V\"", &value[2]);
+            return NGX_CONF_ERROR;
+        }
+    }
+
     switch (gcf->country->databaseType) {
 
     case GEOIP_COUNTRY_EDITION:
@@ -485,6 +496,17 @@
         return NGX_CONF_ERROR;
     }
 
+    if (cf->args->nelts == 3) {
+        if (ngx_strcmp(value[2].data, "utf8") == 0) {
+            GeoIP_set_charset (gcf->city, GEOIP_CHARSET_UTF8);
+
+        } else {
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "invalid parameter \"%V\"", &value[2]);
+            return NGX_CONF_ERROR;
+        }
+    }
+
     switch (gcf->city->databaseType) {
 
     case GEOIP_CITY_EDITION_REV0:
--- a/src/http/modules/ngx_http_proxy_module.c	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/http/modules/ngx_http_proxy_module.c	Mon Feb 21 00:00:00 2011 +0300
@@ -1717,6 +1717,7 @@
     ngx_http_proxy_loc_conf_t *prev = parent;
     ngx_http_proxy_loc_conf_t *conf = child;
 
+    u_char                     *p;
     size_t                      size;
     ngx_keyval_t               *s;
     ngx_hash_init_t             hash;
@@ -1975,13 +1976,25 @@
             }
 
             pr->handler = ngx_http_proxy_rewrite_redirect_text;
-            pr->redirect = conf->url;
 
             if (conf->vars.uri.len) {
+                pr->redirect = conf->url;
                 pr->replacement.text = conf->location;
 
             } else {
-                ngx_str_null(&pr->replacement.text);
+                pr->redirect.len = conf->url.len + sizeof("/") - 1;
+
+                p = ngx_pnalloc(cf->pool, pr->redirect.len);
+                if (p == NULL) {
+                    return NGX_CONF_ERROR;
+                }
+
+                pr->redirect.data = p;
+
+                p = ngx_cpymem(p, conf->url.data, conf->url.len);
+                *p = '/';
+
+                ngx_str_set(&pr->replacement.text, "/");
             }
         }
     }
@@ -2456,6 +2469,7 @@
 {
     ngx_http_proxy_loc_conf_t *plcf = conf;
 
+    u_char                     *p;
     ngx_str_t                  *value;
     ngx_array_t                *vars_lengths, *vars_values;
     ngx_http_script_compile_t   sc;
@@ -2518,13 +2532,25 @@
         }
 
         pr->handler = ngx_http_proxy_rewrite_redirect_text;
-        pr->redirect = plcf->url;
 
         if (plcf->vars.uri.len) {
+            pr->redirect = plcf->url;
             pr->replacement.text = plcf->location;
 
         } else {
-            ngx_str_null(&pr->replacement.text);
+            pr->redirect.len = plcf->url.len + sizeof("/") - 1;
+
+            p = ngx_pnalloc(cf->pool, pr->redirect.len);
+            if (p == NULL) {
+                return NGX_CONF_ERROR;
+            }
+
+            pr->redirect.data = p;
+
+            p = ngx_cpymem(p, plcf->url.data, plcf->url.len);
+            *p = '/';
+
+            ngx_str_set(&pr->replacement.text, "/");
         }
 
         return NGX_CONF_OK;
--- a/src/http/modules/perl/nginx.pm	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/http/modules/perl/nginx.pm	Mon Feb 21 00:00:00 2011 +0300
@@ -48,7 +48,7 @@
     HTTP_INSUFFICIENT_STORAGE
 );
 
-our $VERSION = '0.9.4';
+our $VERSION = '0.9.5';
 
 require XSLoader;
 XSLoader::load('nginx', $VERSION);
--- a/src/http/ngx_http_special_response.c	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/http/ngx_http_special_response.c	Mon Feb 21 00:00:00 2011 +0300
@@ -570,7 +570,14 @@
         return NGX_ERROR;
     }
 
-    r->err_status = overwrite > 0 ? overwrite : NGX_HTTP_MOVED_TEMPORARILY;
+    if (overwrite >= NGX_HTTP_MOVED_PERMANENTLY
+        && overwrite <= NGX_HTTP_SEE_OTHER)
+    {
+        r->err_status = overwrite;
+
+    } else {
+        r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
+    }
 
     location->hash = 1;
     ngx_str_set(&location->key, "Location");
--- a/src/os/unix/ngx_files.c	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/os/unix/ngx_files.c	Mon Feb 21 00:00:00 2011 +0300
@@ -245,7 +245,7 @@
 {
     struct timeval  tv[2];
 
-    tv[0].tv_sec = s;
+    tv[0].tv_sec = ngx_time();
     tv[0].tv_usec = 0;
     tv[1].tv_sec = s;
     tv[1].tv_usec = 0;
--- a/src/os/unix/ngx_linux_config.h	Fri Jan 21 00:00:00 2011 +0300
+++ b/src/os/unix/ngx_linux_config.h	Mon Feb 21 00:00:00 2011 +0300
@@ -88,7 +88,7 @@
 #endif
 
 
-#define NGX_LISTEN_BACKLOG        511
+#define NGX_LISTEN_BACKLOG        -1
 
 
 #if defined TCP_DEFER_ACCEPT && !defined NGX_HAVE_DEFERRED_ACCEPT