nginx-0.3.12-RELEASE import

    *) Security: if nginx was built with the ngx_http_realip_module and the
       "satisfy_any on" directive was used, then access and authorization
       directives did not work. The ngx_http_realip_module was not built
       and is not built by default.

    *) Change: the "$time_gmt" variable name was changed to "$time_local".

    *) Change: the "proxy_header_buffer_size" and
       "fastcgi_header_buffer_size" directives was renamed to the
       "proxy_buffer_size" and "fastcgi_buffer_size" directives.

    *) Feature: the ngx_http_memcached_module.

    *) Feature: the "proxy_buffering" directive.

    *) Bugfix: the changes in accept mutex handling when the "rtsig" method
       was used; the bug had appeared in 0.3.0.

    *) Bugfix: if the client sent the "Transfer-Encoding: chunked" header
       line, then nginx returns the 411 error.

    *) Bugfix: if the "auth_basic" directive was inherited from the http
       level, then the realm in the "WWW-Authenticate" header line was
       without the "Basic realm" text.

    *) Bugfix: if the "combined" format was explicitly specified in the
       "access_log" directive, then the empty lines was written to the log;
       the bug had appeared in 0.3.8.

    *) Bugfix: nginx did not run on the sparc platform under any OS except
       Solaris.

    *) Bugfix: now it is not necessary to place space between the quoted
       string and closing bracket in the "if" directive.
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 95d93cc..44b15f9 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.3.11"
+#define NGINX_VER          "nginx/0.3.12"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_OLDPID_EXT     ".oldbin"
diff --git a/src/core/ngx_buf.c b/src/core/ngx_buf.c
index b7f597d..31d9903 100644
--- a/src/core/ngx_buf.c
+++ b/src/core/ngx_buf.c
@@ -151,6 +151,34 @@
 }
 
 
+ngx_chain_t *
+ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free)
+{
+    ngx_chain_t  *cl;
+
+    if (*free) {
+        cl = *free;
+        *free = cl->next;
+        cl->next = NULL;
+        return cl;
+    }
+
+    cl = ngx_alloc_chain_link(p);
+    if (cl == NULL) {
+        return NULL;
+    }
+
+    cl->buf = ngx_calloc_buf(p);
+    if (cl->buf == NULL) {
+        return NULL;
+    }
+
+    cl->next = NULL;
+
+    return cl;
+}
+
+
 void
 ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
     ngx_chain_t **out, ngx_buf_tag_t tag)
diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h
index 471ab19..625db2a 100644
--- a/src/core/ngx_buf.h
+++ b/src/core/ngx_buf.h
@@ -132,6 +132,7 @@
 
 ngx_int_t ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
     ngx_chain_t *in);
+ngx_chain_t *ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free);
 void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
     ngx_chain_t **out, ngx_buf_tag_t tag);
 
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index acec130..d89fa7f 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -77,8 +77,8 @@
 
         fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
         if (fd == NGX_INVALID_FILE) {
-            ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
-                          ngx_open_file_n " \"%s\" failed", filename->data);
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+                              ngx_open_file_n " \"%s\" failed", filename->data);
             return NGX_CONF_ERROR;
         }
 
@@ -451,12 +451,18 @@
                 return NGX_CONF_BLOCK_START;
             }
 
-            ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
-                          "unexpected \"%c\" in %s:%ui",
-                          ch, cf->conf_file->file.name.data,
-                          cf->conf_file->line);
+            if (ch == ')') {
+                last_space = 1;
+                need_space = 0;
 
-            return NGX_ERROR;
+            } else {
+                 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+                               "unexpected \"%c\" in %s:%ui",
+                               ch, cf->conf_file->file.name.data,
+                               cf->conf_file->line);
+
+                 return NGX_ERROR;
+            }
         }
 
         if (last_space) {
@@ -1167,6 +1173,20 @@
 
 
 char *
+ngx_conf_deprecated(ngx_conf_t *cf, void *post, void *data)
+{
+    ngx_conf_deprecated_t  *d = post;
+
+    ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
+                       "the \"%s\" directive is deprecated, "
+                       "use the \"%s\" directive instead",
+                       d->old_name, d->new_name);
+
+    return NGX_CONF_OK;
+}
+
+
+char *
 ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data)
 {
     ngx_conf_num_bounds_t  *bounds = post;
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 2ef595d..e1859f8 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -189,6 +189,13 @@
 
 typedef struct {
     ngx_conf_post_handler_pt  post_handler;
+    char                     *old_name;
+    char                     *new_name;
+} ngx_conf_deprecated_t;
+
+
+typedef struct {
+    ngx_conf_post_handler_pt  post_handler;
     ngx_int_t                 low;
     ngx_int_t                 high;
 } ngx_conf_num_bounds_t;
@@ -208,6 +215,8 @@
 } ngx_conf_bitmask_t;
 
 
+
+char * ngx_conf_deprecated(ngx_conf_t *cf, void *post, void *data);
 char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data);
 
 
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index 3b51e96..96569b8 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -76,32 +76,30 @@
 
 #if 1
 /* STUB: autoconf */
-typedef int                ngx_int_t;
-typedef u_int              ngx_uint_t;
-typedef int                ngx_flag_t;
-#define NGX_INT_T_LEN      sizeof("-2147483648") - 1
+typedef int             ngx_int_t;
+typedef u_int           ngx_uint_t;
+typedef int             ngx_flag_t;
+#define NGX_INT_T_LEN   sizeof("-2147483648") - 1
 
 #else
 
-typedef long               ngx_int_t;
-typedef u_long             ngx_uint_t;
-typedef long               ngx_flag_t;
-#define NGX_INT_T_LEN      sizeof("-9223372036854775808") - 1
+typedef long            ngx_int_t;
+typedef u_long          ngx_uint_t;
+typedef long            ngx_flag_t;
+#define NGX_INT_T_LEN   sizeof("-9223372036854775808") - 1
 
 #endif
 
-#define NGX_INT32_LEN      sizeof("-2147483648") - 1
-#define NGX_INT64_LEN      sizeof("-9223372036854775808") - 1
+#define NGX_INT32_LEN   sizeof("-2147483648") - 1
+#define NGX_INT64_LEN   sizeof("-9223372036854775808") - 1
 
 
-#if (NGX_SOLARIS)
-#define NGX_ALIGN       (_MAX_ALIGNMENT - 1)
-#else
-/* TODO: auto_conf */
-#define NGX_ALIGN       (sizeof(unsigned long) - 1)  /* platform word */
+#ifndef NGX_ALIGNMENT
+#define NGX_ALIGNMENT   sizeof(unsigned long)    /* platform word */
 #endif
 
-#define ngx_align(p)    (u_char *) (((uintptr_t) p + NGX_ALIGN) & ~NGX_ALIGN)
+#define ngx_align(p)    (u_char *) (((uintptr_t) p + (NGX_ALIGNMENT - 1))     \
+                                      & ~(NGX_ALIGNMENT - 1))
 
 
 #define ngx_abort       abort
@@ -109,7 +107,7 @@
 
 /* TODO: auto_conf: ngx_inline   inline __inline __inline__ */
 #ifndef ngx_inline
-#define ngx_inline   inline
+#define ngx_inline      inline
 #endif
 
 #define NGX_ACCEPT_THRESHOLD   100
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
index d44e300..ee68fc1 100644
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -12,8 +12,8 @@
 
 /*
  * ngx_sock_ntop() and ngx_inet_ntop() may be implemented as
- * "ngx_sprintf(text, "%ud.%ud.%ud.%ud", p[0], p[1], p[2], p[3])",
- * however, they were implemented long before the ngx_sprintf() appeared
+ * "ngx_sprintf(text, "%ud.%ud.%ud.%ud", p[0], p[1], p[2], p[3])", however,
+ * they had been implemented long before the ngx_sprintf() had appeared
  * and they are faster by 1.5-2.5 times, so it is worth to keep them.
  *
  * By the way, the implementation using ngx_sprintf() is faster by 2.5-3 times
diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c
index d1e7bbd..a1f9d59 100644
--- a/src/core/ngx_palloc.c
+++ b/src/core/ngx_palloc.c
@@ -20,9 +20,10 @@
 
     p->last = (u_char *) p + sizeof(ngx_pool_t);
     p->end = (u_char *) p + size;
+    p->current = p;
+    p->chain = NULL;
     p->next = NULL;
     p->large = NULL;
-    p->chain = NULL;
     p->cleanup = NULL;
     p->log = log;
 
@@ -91,7 +92,7 @@
         && size <= (size_t) (pool->end - (u_char *) pool)
                                      - (size_t) ngx_align(sizeof(ngx_pool_t)))
     {
-        for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
+        for (p = pool->current; /* void */ ; p = p->next) {
             m = ngx_align(p->last);
 
             if ((size_t) (p->end - m) >= size) {
@@ -100,7 +101,11 @@
                 return m;
             }
 
-            if (n == NULL) {
+            if ((size_t) (p->end - m) < NGX_ALIGNMENT) {
+                p->current = p->next;
+            }
+
+            if (p->next == NULL) {
                 break;
             }
         }
@@ -112,6 +117,10 @@
             return NULL;
         }
 
+        if (p->current == NULL) {
+            p->current = n;
+        }
+
         p->next = n;
         m = ngx_align(n->last);
         n->last = m + size;
diff --git a/src/core/ngx_palloc.h b/src/core/ngx_palloc.h
index b8b1692..30590ee 100644
--- a/src/core/ngx_palloc.h
+++ b/src/core/ngx_palloc.h
@@ -44,6 +44,7 @@
 struct ngx_pool_s {
     u_char               *last;
     u_char               *end;
+    ngx_pool_t           *current;
     ngx_chain_t          *chain;
     ngx_pool_t           *next;
     ngx_pool_large_t     *large;