diff src/http/modules/ngx_http_chunked_filter.c @ 10:46833bd150cb NGINX_0_1_5

nginx 0.1.5 *) Bugfix: on Solaris and Linux there may be too many "recvmsg() returned not enough data" alerts. *) Bugfix: there were the "writev() failed (22: Invalid argument)" errors on Solaris in proxy mode without sendfile. On other platforms that do not support sendfile at all the process got caught in an endless loop. *) Bugfix: segmentation fault on Solaris in proxy mode and using sendfile. *) Bugfix: segmentation fault on Solaris. *) Bugfix: on-line upgrade did not work on Linux. *) Bugfix: the ngx_http_autoindex_module module did not escape the spaces, the quotes, and the percent signs in the directory listing. *) Change: the decrease of the copy operations. *) Feature: the userid_p3p directive.
author Igor Sysoev <http://sysoev.ru>
date Thu, 11 Nov 2004 00:00:00 +0300
parents 4b2dafa26fe2
children 8b6db3bda591
line wrap: on
line diff
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -32,7 +32,7 @@ ngx_module_t  ngx_http_chunked_filter_mo
     NULL,                                  /* module directives */
     NGX_HTTP_MODULE,                       /* module type */
     ngx_http_chunked_filter_init,          /* init module */
-    NULL                                   /* init child */
+    NULL                                   /* init process */
 };
 
 
@@ -84,7 +84,11 @@ static ngx_int_t ngx_http_chunked_body_f
         size += ngx_buf_size(cl->buf);
 
         if (cl->buf->flush || ngx_buf_in_memory(cl->buf) || cl->buf->in_file) {
-            ngx_test_null(tl, ngx_alloc_chain_link(r->pool), NGX_ERROR);
+
+            if (!(tl = ngx_alloc_chain_link(r->pool))) {
+                return NGX_ERROR;
+            }
+
             tl->buf = cl->buf;
             *ll = tl;
             ll = &tl->next;
@@ -102,30 +106,22 @@ static ngx_int_t ngx_http_chunked_body_f
             return NGX_ERROR;
         }
 
-        if (!(chunk = ngx_palloc(r->pool, 11))) {
+        if (!(chunk = ngx_palloc(r->pool, sizeof("00000000" CRLF) - 1))) {
             return NGX_ERROR;
         }
 
         b->temporary = 1;
         b->pos = chunk;
-        b->last = ngx_sprintf(chunk, "%uxS" CRLF, size);
+        b->last = ngx_sprintf(chunk, "%xz" CRLF, size);
 
         out.buf = b;
-#if 0
-        ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
-        len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
-
-        ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
-        b->temporary = 1;
-        b->pos = chunk;
-        b->last = chunk + len;
-
-        out.buf = b;
-#endif
     }
 
     if (cl->buf->last_buf) {
-        ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+        if (!(b = ngx_calloc_buf(r->pool))) {
+            return NGX_ERROR;
+        }
+
         b->memory = 1;
         b->last_buf = 1;
         b->pos = (u_char *) CRLF "0" CRLF CRLF;
@@ -147,7 +143,10 @@ static ngx_int_t ngx_http_chunked_body_f
             return ngx_http_next_body_filter(r, out.next);
         }
 
-        ngx_test_null(b, ngx_calloc_buf(r->pool), NGX_ERROR);
+        if (!(b = ngx_calloc_buf(r->pool))) {
+            return NGX_ERROR;
+        }
+
         b->memory = 1;
         b->pos = (u_char *) CRLF;
         b->last = b->pos + 2;