Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_memcached_module.c @ 1611:d5db0e96bcc6 stable-0.5
r1542, r1543, r1544, r1549, r1550, r1551, r1555 merge:
*) ngx_strstrn() and ngx_strcasestrn()
*) fix memcached END test
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 29 Oct 2007 14:52:51 +0000 |
parents | 142d979bc738 |
children | a33e2a1a4e4c |
comparison
equal
deleted
inserted
replaced
1610:f5e9d597a751 | 1611:d5db0e96bcc6 |
---|---|
423 b = &u->buffer; | 423 b = &u->buffer; |
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 | 428 ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - ctx->rest, |
429 - ctx->rest, | 429 ctx->rest) |
430 bytes) != 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; |