diff src/http/modules/ngx_http_gzip_filter.c @ 346:55e496a8ece3

nginx-0.0.3-2004-06-06-23:49:18 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 06 Jun 2004 19:49:18 +0000
parents e366ba5db8f8
children 0fb6c53fb135
line wrap: on
line diff
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -317,7 +317,7 @@ static int ngx_http_gzip_header_filter(n
         r->headers_out.content_length->key.len = 0;
         r->headers_out.content_length = NULL;
     }
-    r->filter |= NGX_HTTP_FILTER_NEED_IN_MEMORY;
+    r->filter_need_in_memory = 1;
 
     return ngx_http_next_header_filter(r);
 }
@@ -438,12 +438,12 @@ static int ngx_http_gzip_body_filter(ngx
          * We preallocate a memory for zlib in one buffer (200K-400K), this
          * dicreases a number of malloc() and free() calls and also probably
          * dicreases a number of syscalls (sbrk() or so).
-         * Besides we free() this memory as soon as the gzipping will complete
+         * Besides we free this memory as soon as the gzipping will complete
          * and do not wait while a whole response will be sent to a client.
          *
          * 8K is for zlib deflate_state (~6K).
          *
-         * TODO: 64-bit, round to PAGE_SIZE, autoconf of deflate_state size
+         * TODO: 64-bit, autoconf of deflate_state size
          */
 
         ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9));
@@ -739,10 +739,12 @@ static void *ngx_http_gzip_filter_alloc(
     alloc = items * size;
     if (alloc % 512 != 0) {
 
-        /* we allocate 8K for zlib deflate_state (~6K) */
-        /* TODO: PAGE_SIZE */
+        /*
+         * allocate the zlib deflate_state, it takes about 6K on x86,
+         * we allocate 8K
+         */
 
-        alloc = (alloc + 4095) & ~4095;
+        alloc = (alloc + ngx_pagesize - 1) & ~(ngx_pagesize - 1);
     }
 
     if (alloc <= ctx->allocated) {
@@ -900,8 +902,7 @@ static char *ngx_http_gzip_merge_conf(ng
 
     ngx_conf_merge_value(conf->enable, prev->enable, 0);
 
-    ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4,
-                              /* STUB: PAGE_SIZE */ 4096);
+    ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4, ngx_pagesize);
 
     ngx_conf_merge_unsigned_value(conf->http_version, prev->http_version,
                                   NGX_HTTP_VERSION_11);