comparison src/http/modules/ngx_http_memcached_module.c @ 1554:30fcc8478d85

two commits those go together by mistake *) fix gzip broken in r1544 *) fix memcached END test
author Igor Sysoev <igor@sysoev.ru>
date Mon, 01 Oct 2007 16:00:13 +0000
parents a83aa8c53552
children 31d4278d51c0
comparison
equal deleted inserted replaced
1553:e3134867a810 1554:30fcc8478d85
424 424
425 if (u->length == ctx->rest) { 425 if (u->length == ctx->rest) {
426 426
427 if (ngx_strncmp(b->last, 427 if (ngx_strncmp(b->last,
428 ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - ctx->rest, 428 ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - ctx->rest,
429 bytes) 429 ctx->rest)
430 != 0) 430 != 0)
431 { 431 {
432 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, 432 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
433 "memcached sent invalid trailer"); 433 "memcached sent invalid trailer");
434 } 434 }
435 435
436 u->length -= bytes; 436 u->length = 0;
437 ctx->rest -= bytes; 437 ctx->rest = 0;
438 438
439 return NGX_OK; 439 return NGX_OK;
440 } 440 }
441 441
442 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) { 442 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) {
451 cl->buf->flush = 1; 451 cl->buf->flush = 1;
452 cl->buf->memory = 1; 452 cl->buf->memory = 1;
453 453
454 *ll = cl; 454 *ll = cl;
455 455
456 cl->buf->pos = b->last; 456 last = b->last;
457 cl->buf->pos = last;
457 b->last += bytes; 458 b->last += bytes;
458 cl->buf->last = b->last; 459 cl->buf->last = b->last;
459 460
460 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, 461 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
461 "memcached filter bytes:%z size:%z length:%z rest:%z", 462 "memcached filter bytes:%z size:%z length:%z rest:%z",
462 bytes, b->last - b->pos, u->length, ctx->rest); 463 bytes, b->last - b->pos, u->length, ctx->rest);
463 464
464 if (b->last - b->pos <= (ssize_t) (u->length - NGX_HTTP_MEMCACHED_END)) { 465 if (bytes <= (ssize_t) (u->length - NGX_HTTP_MEMCACHED_END)) {
465 u->length -= bytes; 466 u->length -= bytes;
466 return NGX_OK; 467 return NGX_OK;
467 } 468 }
468 469
469 470 last += u->length - NGX_HTTP_MEMCACHED_END;
470 last = b->pos + u->length - NGX_HTTP_MEMCACHED_END;
471 471
472 if (ngx_strncmp(last, ngx_http_memcached_end, b->last - last) != 0) { 472 if (ngx_strncmp(last, ngx_http_memcached_end, b->last - last) != 0) {
473 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, 473 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
474 "memcached sent invalid trailer"); 474 "memcached sent invalid trailer");
475 } 475 }
476 476
477 ctx->rest = u->length - (b->last - b->pos); 477 ctx->rest -= b->last - last;
478 b->last = last; 478 b->last = last;
479 cl->buf->last = last; 479 cl->buf->last = last;
480 u->length = ctx->rest; 480 u->length = ctx->rest;
481 481
482 return NGX_OK; 482 return NGX_OK;