Changeset ef28d8


Ignore:
Timestamp:
02/04/08 14:43:17 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master-v0.7, gunzip, master-v0.6, memcached_gzip, upstream_count_limit
Children:
ec81a7
Parents:
2bbdb3
git-author:
Tomash Brechko <tomash.brechko@…> (02/04/08 14:43:17)
git-committer:
Tomash Brechko <tomash.brechko@…> (02/04/08 14:43:17)
Message:

Workaround for the infinite loop that is caused by empty input buffer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/src/http/modules/ngx_http_gzip_filter_module.c

    r2bbdb3 ref28d8  
    456456 
    457457                if (ctx->in_buf->last_buf) { 
    458                     ctx->flush = Z_FINISH; 
     458                    /* 
     459                     * We use Z_BLOCK below for the following reason: 
     460                     * if we would use Z_FINISH, then decompression 
     461                     * may return Z_BUF_ERROR, meaning there wasn't 
     462                     * enough room for decompressed data.  This error 
     463                     * is not fatal according to zlib.h, however 
     464                     * ignoring it is dangerous and may mask real 
     465                     * bugs.  For instance, sometimes completely empty 
     466                     * last buffer is passed to this filter, and 
     467                     * decompression would enter the infinite loop: no 
     468                     * progress is possible because input is void and 
     469                     * Z_BUF_ERROR is ignored.  We can't use 
     470                     * Z_NO_FLUSH, because it will never return 
     471                     * Z_STREAM_END.  We can't use Z_SYNC_FLUSH, 
     472                     * because it has a special meaning.  So we use 
     473                     * Z_BLOCK, which eventually would return 
     474                     * Z_STREAM_END. 
     475                     * 
     476                     * Perhaps the above is also true for compression, 
     477                     * but right now we won't try to change the old 
     478                     * behaviour. 
     479                     */ 
     480                    ctx->flush = (!r->gunzip ? Z_FINISH : Z_BLOCK); 
    459481 
    460482                } else if (ctx->in_buf->flush) { 
     
    515537            } 
    516538 
    517             if (rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) { 
     539            if (rc != Z_OK && rc != Z_STREAM_END) { 
    518540                ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 
    519541                              "deflate() failed: %d, %d", ctx->flush, rc); 
Note: See TracChangeset for help on using the changeset viewer.