comparison src/http/modules/ngx_http_memcached_module.c @ 340:10cc350ed8a1 NGINX_0_6_14

nginx 0.6.14 *) Change: now by default the "echo" SSI command uses entity encoding. *) Feature: the "encoding" parameter in the "echo" SSI command. *) Feature: the "access_log" directive may be used inside the "limit_except" block. *) Bugfix: if all upstream servers were failed, then all servers had got weight the was equal one until servers became alive; bug appeared in 0.6.6. *) Bugfix: a segmentation fault occurred in worker process if $date_local and $date_gmt were used outside the ngx_http_ssi_filter_module. *) Bugfix: a segmentation fault might occur in worker process if debug log was enabled. Thanks to Andrei Nigmatulin. *) Bugfix: ngx_http_memcached_module did not set $upstream_response_time. Thanks to Maxim Dounin. *) Bugfix: a worker process may got caught in an endless loop, if the memcached was used. *) Bugfix: nginx supported low case only "close" and "keep-alive" values in the "Connection" request header line; bug appeared in 0.6.11. *) Bugfix: sub_filter did not work with empty substitution. *) Bugfix: in sub_filter parsing.
author Igor Sysoev <http://sysoev.ru>
date Mon, 15 Oct 2007 00:00:00 +0400
parents 9fc4ab6673f9
children e10168d6e371
comparison
equal deleted inserted replaced
339:d19550b67059 340:10cc350ed8a1
369 &line, &ctx->key); 369 &line, &ctx->key);
370 return NGX_HTTP_UPSTREAM_INVALID_HEADER; 370 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
371 } 371 }
372 372
373 u->headers_in.status_n = 200; 373 u->headers_in.status_n = 200;
374 u->state->status = 200;
374 u->buffer.pos = p + 1; 375 u->buffer.pos = p + 1;
375 376
376 return NGX_OK; 377 return NGX_OK;
377 } 378 }
378 379
379 if (ngx_strcmp(p, "END\x0d") == 0) { 380 if (ngx_strcmp(p, "END\x0d") == 0) {
380 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 381 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
381 "key: \"%V\" was not found by memcached", &ctx->key); 382 "key: \"%V\" was not found by memcached", &ctx->key);
382 383
383 u->headers_in.status_n = 404; 384 u->headers_in.status_n = 404;
385 u->state->status = 404;
384 386
385 return NGX_OK; 387 return NGX_OK;
386 } 388 }
387 389
388 no_valid: 390 no_valid:
423 b = &u->buffer; 425 b = &u->buffer;
424 426
425 if (u->length == ctx->rest) { 427 if (u->length == ctx->rest) {
426 428
427 if (ngx_strncmp(b->last, 429 if (ngx_strncmp(b->last,
428 ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END 430 ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - ctx->rest,
429 - ctx->rest, 431 ctx->rest)
430 bytes) != 0) 432 != 0)
431 { 433 {
432 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, 434 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
433 "memcached sent invalid trailer"); 435 "memcached sent invalid trailer");
434 } 436 }
435 437
436 u->length -= bytes; 438 u->length = 0;
437 ctx->rest -= bytes; 439 ctx->rest = 0;
438 440
439 return NGX_OK; 441 return NGX_OK;
440 } 442 }
441 443
442 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) { 444 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) {
451 cl->buf->flush = 1; 453 cl->buf->flush = 1;
452 cl->buf->memory = 1; 454 cl->buf->memory = 1;
453 455
454 *ll = cl; 456 *ll = cl;
455 457
456 cl->buf->pos = b->last; 458 last = b->last;
459 cl->buf->pos = last;
457 b->last += bytes; 460 b->last += bytes;
458 cl->buf->last = b->last; 461 cl->buf->last = b->last;
459 462
460 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, 463 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
461 "memcached filter bytes:%z size:%z length:%z rest:%z", 464 "memcached filter bytes:%z size:%z length:%z rest:%z",
462 bytes, b->last - b->pos, u->length, ctx->rest); 465 bytes, b->last - b->pos, u->length, ctx->rest);
463 466
464 if (b->last - b->pos <= (ssize_t) (u->length - NGX_HTTP_MEMCACHED_END)) { 467 if (bytes <= (ssize_t) (u->length - NGX_HTTP_MEMCACHED_END)) {
465 u->length -= bytes; 468 u->length -= bytes;
466 return NGX_OK; 469 return NGX_OK;
467 } 470 }
468 471
469 472 last += u->length - NGX_HTTP_MEMCACHED_END;
470 last = b->pos + u->length - NGX_HTTP_MEMCACHED_END;
471 473
472 if (ngx_strncmp(last, ngx_http_memcached_end, b->last - last) != 0) { 474 if (ngx_strncmp(last, ngx_http_memcached_end, b->last - last) != 0) {
473 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, 475 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
474 "memcached sent invalid trailer"); 476 "memcached sent invalid trailer");
475 } 477 }
476 478
477 ctx->rest = u->length - (b->last - b->pos); 479 ctx->rest -= b->last - last;
478 b->last = last; 480 b->last = last;
479 cl->buf->last = last; 481 cl->buf->last = last;
480 u->length = ctx->rest; 482 u->length = ctx->rest;
481 483
482 return NGX_OK; 484 return NGX_OK;