Mercurial > hg > nginx
diff 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 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_memcached_module.c Mon Oct 29 14:35:37 2007 +0000 +++ b/src/http/modules/ngx_http_memcached_module.c Mon Oct 29 14:52:51 2007 +0000 @@ -425,16 +425,16 @@ if (u->length == ctx->rest) { if (ngx_strncmp(b->last, - ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - - ctx->rest, - bytes) != 0) + ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - ctx->rest, + ctx->rest) + != 0) { ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, "memcached sent invalid trailer"); } - u->length -= bytes; - ctx->rest -= bytes; + u->length = 0; + ctx->rest = 0; return NGX_OK; } @@ -453,7 +453,8 @@ *ll = cl; - cl->buf->pos = b->last; + last = b->last; + cl->buf->pos = last; b->last += bytes; cl->buf->last = b->last; @@ -461,20 +462,19 @@ "memcached filter bytes:%z size:%z length:%z rest:%z", bytes, b->last - b->pos, u->length, ctx->rest); - if (b->last - b->pos <= (ssize_t) (u->length - NGX_HTTP_MEMCACHED_END)) { + if (bytes <= (ssize_t) (u->length - NGX_HTTP_MEMCACHED_END)) { u->length -= bytes; return NGX_OK; } - - last = b->pos + u->length - NGX_HTTP_MEMCACHED_END; + last += u->length - NGX_HTTP_MEMCACHED_END; if (ngx_strncmp(last, ngx_http_memcached_end, b->last - last) != 0) { ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, "memcached sent invalid trailer"); } - ctx->rest = u->length - (b->last - b->pos); + ctx->rest -= b->last - last; b->last = last; cl->buf->last = last; u->length = ctx->rest;