Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_gzip_filter.c @ 257:70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 11 Feb 2004 17:08:49 +0000 |
parents | bf2faf694c19 |
children | 6468241715e6 |
comparison
equal
deleted
inserted
replaced
256:8e39cab6abd5 | 257:70e1c7d2b83d |
---|---|
375 | 375 |
376 ctx->zstream.next_out = (u_char *) ctx->out_hunk->pos; | 376 ctx->zstream.next_out = (u_char *) ctx->out_hunk->pos; |
377 ctx->zstream.avail_out = conf->bufs.size; | 377 ctx->zstream.avail_out = conf->bufs.size; |
378 } | 378 } |
379 | 379 |
380 ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _ | 380 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
381 ctx->zstream.next_in _ ctx->zstream.next_out _ | 381 "deflate in: ni:%X no:%X ai:%d ao:%d fl:%d", |
382 ctx->zstream.avail_in _ ctx->zstream.avail_out _ ctx->flush); | 382 ctx->zstream.next_in, ctx->zstream.next_out, |
383 ctx->zstream.avail_in, ctx->zstream.avail_out, | |
384 ctx->flush); | |
383 | 385 |
384 rc = deflate(&ctx->zstream, ctx->flush); | 386 rc = deflate(&ctx->zstream, ctx->flush); |
385 if (rc != Z_OK && rc != Z_STREAM_END) { | 387 if (rc != Z_OK && rc != Z_STREAM_END) { |
386 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | 388 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
387 "deflate() failed: %d, %d", ctx->flush, rc); | 389 "deflate() failed: %d, %d", ctx->flush, rc); |
388 return ngx_http_gzip_error(ctx); | 390 return ngx_http_gzip_error(ctx); |
389 } | 391 } |
390 | 392 |
391 ngx_log_debug(r->connection->log, "DEFLATE(): %08x %08x %d %d %d" _ | 393 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
392 ctx->zstream.next_in _ ctx->zstream.next_out _ | 394 "deflate out: ni:%X no:%X ai:%d ao:%d rc:%d", |
393 ctx->zstream.avail_in _ ctx->zstream.avail_out _ rc); | 395 ctx->zstream.next_in, ctx->zstream.next_out, |
396 ctx->zstream.avail_in, ctx->zstream.avail_out, | |
397 rc); | |
394 | 398 |
395 ctx->in_hunk->pos = (char *) ctx->zstream.next_in; | 399 ctx->in_hunk->pos = (char *) ctx->zstream.next_in; |
396 ctx->out_hunk->last = (char *) ctx->zstream.next_out; | 400 ctx->out_hunk->last = (char *) ctx->zstream.next_out; |
397 | 401 |
398 if (ctx->zstream.avail_out == 0) { | 402 if (ctx->zstream.avail_out == 0) { |
510 ngx_http_gzip_ctx_t *ctx = opaque; | 514 ngx_http_gzip_ctx_t *ctx = opaque; |
511 | 515 |
512 int alloc; | 516 int alloc; |
513 void *p; | 517 void *p; |
514 | 518 |
515 | |
516 alloc = items * size; | 519 alloc = items * size; |
517 if (alloc % 512 != 0) { | 520 if (alloc % 512 != 0) { |
518 | 521 |
519 /* we allocate 8K for zlib deflate_state (~6K) */ | 522 /* we allocate 8K for zlib deflate_state (~6K) */ |
520 /* TODO: PAGE_SIZE */ | 523 /* TODO: PAGE_SIZE */ |
525 if (alloc <= ctx->allocated) { | 528 if (alloc <= ctx->allocated) { |
526 p = ctx->free_mem; | 529 p = ctx->free_mem; |
527 ctx->free_mem += alloc; | 530 ctx->free_mem += alloc; |
528 ctx->allocated -= alloc; | 531 ctx->allocated -= alloc; |
529 | 532 |
530 #if 1 | 533 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, |
531 ngx_log_debug(ctx->request->connection->log, "ALLOC: %d:%d:%d:%08X" _ | 534 "gzip alloc: n:%d s:%d a:%d p:%08X", |
532 items _ size _ alloc _ p); | 535 items, size, alloc, p); |
533 #endif | |
534 | 536 |
535 return p; | 537 return p; |
536 } | 538 } |
537 | 539 |
538 ngx_log_error(NGX_LOG_ALERT, ctx->request->connection->log, 0, | 540 ngx_log_error(NGX_LOG_ALERT, ctx->request->connection->log, 0, |
548 static void ngx_http_gzip_filter_free(void *opaque, void *address) | 550 static void ngx_http_gzip_filter_free(void *opaque, void *address) |
549 { | 551 { |
550 ngx_http_gzip_ctx_t *ctx = opaque; | 552 ngx_http_gzip_ctx_t *ctx = opaque; |
551 | 553 |
552 #if 0 | 554 #if 0 |
553 ngx_log_debug(ctx->request->connection->log, "FREE: %08X" _ address); | 555 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, |
556 "gzip free: %X", address); | |
554 #endif | 557 #endif |
555 } | 558 } |
556 | 559 |
557 | 560 |
558 static char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, char *buf, | 561 static char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, char *buf, |