From ce151cd91e5cd1c53dea773e624c233c8a469c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?agentzh=20=28=E7=AB=A0=E4=BA=A6=E6=98=A5=29?= Date: Mon, 29 Nov 2010 17:09:08 +0800 Subject: [PATCH 1/3] minor style fixes. --- src/ngx_http_memc_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ngx_http_memc_module.c b/src/ngx_http_memc_module.c index 0de9699..29a6577 100644 --- a/src/ngx_http_memc_module.c +++ b/src/ngx_http_memc_module.c @@ -247,7 +247,7 @@ ngx_http_memc_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) static char * ngx_http_memc_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_http_memc_loc_conf_t *mlcf = conf; + ngx_http_memc_loc_conf_t *mlcf = conf; ngx_str_t *value; ngx_url_t url; From 8eced6d5cb3ad481faf816d54fefe90e679a7c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?agentzh=20=28=E7=AB=A0=E4=BA=A6=E6=98=A5=29?= Date: Sun, 5 Dec 2010 22:07:06 +0800 Subject: [PATCH 2/3] added an error message when no upstream backend is found in memc_pass $backend; --- .gitignore | 1 - src/ngx_http_memc_handler.c | 4 +++- test/t/errors.t | 31 +++++++++++++++++++++++++++++++ util/build.sh | 8 ++++---- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 test/t/errors.t diff --git a/.gitignore b/.gitignore index b5efdd0..6515be3 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,3 @@ src/request.h src/request.c ctags nginx -t diff --git a/src/ngx_http_memc_handler.c b/src/ngx_http_memc_handler.c index e29ae97..5dc7eb2 100644 --- a/src/ngx_http_memc_handler.c +++ b/src/ngx_http_memc_handler.c @@ -195,7 +195,9 @@ ngx_http_memc_handler(ngx_http_request_t *r) mlcf->upstream.upstream = ngx_http_memc_upstream_add(r, &url); if (mlcf->upstream.upstream == NULL) { - dd("memc: upstream \"%.*s\" not found", target.len, target.data); + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "memc: upstream \"%V\" not found", &target); + return NGX_HTTP_INTERNAL_SERVER_ERROR; } } diff --git a/test/t/errors.t b/test/t/errors.t new file mode 100644 index 0000000..10033a1 --- /dev/null +++ b/test/t/errors.t @@ -0,0 +1,31 @@ +# vi:filetype=perl + +use lib 'lib'; +use Test::Nginx::LWP; + +plan tests => repeat_each() * 2 * blocks(); + +$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211; + +#no_diff; + +run_tests(); + +__DATA__ + + +=== TEST 8: empty pass +little-endian systems only + +--- http_config eval: $::http_config +--- config + location /memc { + set $memc_key foo; + set $backend "not-exist"; + memc_pass $backend; + } +--- request +GET /memc +--- error_code: 500 +--- response_body_like: 500 Internal Server Error + diff --git a/util/build.sh b/util/build.sh index 7c9d3f6..2729086 100755 --- a/util/build.sh +++ b/util/build.sh @@ -2,7 +2,7 @@ # this file is mostly meant to be used by the author himself. -ragel -I src -G2 src/ngx_http_memc_response.rl +#ragel -I src -G2 src/ngx_http_memc_response.rl if [ $? != 0 ]; then echo 'Failed to generate the memcached response parser.' 1>&2 @@ -25,8 +25,8 @@ if [ ! -s "nginx-$version.tar.gz" ]; then fi #tar -xzvf nginx-$version.tar.gz || exit 1 -#cp $root/../no-pool-nginx/nginx-0.8.41-no_pool.patch ./ -#patch -p0 < nginx-0.8.41-no_pool.patch +#cp $root/../no-pool-nginx/nginx-0.8.53-no_pool.patch ./ +#patch -p0 < nginx-0.8.53-no_pool.patch if [ -n "$2" ]; then cd nginx-$version-$2/ @@ -40,7 +40,7 @@ if [[ "$BUILD_CLEAN" -eq 1 || ! -f Makefile || "$root/config" -nt Makefile || "$ --add-module=$root $opts \ --add-module=$root/../eval-nginx-module \ --add-module=$root/../echo-nginx-module \ - --add-module=$home/work/nginx/ngx_http_upstream_keepalive-2ce9d8a1ca93 \ + --add-module=$home/work/nginx/ngx_http_upstream_keepalive-cad8bc39d98d \ --with-debug #--add-module=$home/work/nginx/nginx_upstream_hash-0.3 \ #--without-http_ssi_module # we cannot disable ssi because echo_location_async depends on it (i dunno why?!) From 15c93037b1f97d8fd83f1fa33e1381bcd8273f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?agentzh=20=28=E7=AB=A0=E4=BA=A6=E6=98=A5=29?= Date: Sun, 5 Dec 2010 22:18:55 +0800 Subject: [PATCH 3/3] reindexed the test serial numbers. --- test/t/errors.t | 3 +-- test/t/stats.t | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/t/errors.t b/test/t/errors.t index 10033a1..b25a37b 100644 --- a/test/t/errors.t +++ b/test/t/errors.t @@ -13,8 +13,7 @@ run_tests(); __DATA__ - -=== TEST 8: empty pass +=== TEST 1: empty pass little-endian systems only --- http_config eval: $::http_config diff --git a/test/t/stats.t b/test/t/stats.t index e95c747..d3b58df 100644 --- a/test/t/stats.t +++ b/test/t/stats.t @@ -27,7 +27,8 @@ __DATA__ --- response_body_like: ^(?:STAT [^\r]*\r\n)*END\r\n$ -=== TEST 1: timeout + +=== TEST 2: timeout --- config memc_connect_timeout 10ms; memc_send_timeout 10ms;