mirror of
https://github.com/openresty/openresty.git
synced 2024-10-13 00:29:41 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
009db177df | |||
7e359ff049 | |||
9f52ad4a45 | |||
a925be09c9 | |||
d91993fc38 | |||
0a9a7012dc | |||
c9f5ca8566 | |||
7495a32ec2 |
46
patches/nginx-1.2.7-run_posted_requests_in_resolver.patch
Normal file
46
patches/nginx-1.2.7-run_posted_requests_in_resolver.patch
Normal file
@ -0,0 +1,46 @@
|
||||
diff -ruNp nginx-1.2.7/src/http/ngx_http_upstream.c nginx-1.2.7_zls/src/http/ngx_http_upstream.c
|
||||
--- nginx-1.2.7/src/http/ngx_http_upstream.c 2013-02-18 23:08:46.000000000 +0800
|
||||
+++ nginx-1.2.7_zls/src/http/ngx_http_upstream.c 2013-03-13 00:01:01.490582380 +0800
|
||||
@@ -878,11 +878,13 @@ ngx_http_upstream_cache_send(ngx_http_re
|
||||
static void
|
||||
ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx)
|
||||
{
|
||||
+ ngx_connection_t *c;
|
||||
ngx_http_request_t *r;
|
||||
ngx_http_upstream_t *u;
|
||||
ngx_http_upstream_resolved_t *ur;
|
||||
|
||||
r = ctx->data;
|
||||
+ c = r->connection;
|
||||
|
||||
u = r->upstream;
|
||||
ur = u->resolved;
|
||||
@@ -894,7 +896,8 @@ ngx_http_upstream_resolve_handler(ngx_re
|
||||
ngx_resolver_strerror(ctx->state));
|
||||
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
|
||||
- return;
|
||||
+
|
||||
+ goto posted_requests;
|
||||
}
|
||||
|
||||
ur->naddrs = ctx->naddrs;
|
||||
@@ -919,13 +922,17 @@ ngx_http_upstream_resolve_handler(ngx_re
|
||||
if (ngx_http_upstream_create_round_robin_peer(r, ur) != NGX_OK) {
|
||||
ngx_http_upstream_finalize_request(r, u,
|
||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
- return;
|
||||
+ goto posted_requests;
|
||||
}
|
||||
|
||||
ngx_resolve_name_done(ctx);
|
||||
ur->ctx = NULL;
|
||||
|
||||
ngx_http_upstream_connect(r, u);
|
||||
+
|
||||
+posted_requests:
|
||||
+
|
||||
+ ngx_http_run_posted_requests(c);
|
||||
}
|
||||
|
||||
|
190
patches/ngx_http_redis-0.3.6-variables_in_redis_pass.patch
Normal file
190
patches/ngx_http_redis-0.3.6-variables_in_redis_pass.patch
Normal file
@ -0,0 +1,190 @@
|
||||
--- ngx_http_redis-0.3.6/ngx_http_redis_module.c 2013-03-21 17:51:09.224660165 -0700
|
||||
+++ ngx_http_redis-0.3.6-patched/ngx_http_redis_module.c 2013-03-21 17:50:51.928599875 -0700
|
||||
@@ -18,6 +18,8 @@ typedef struct {
|
||||
ngx_int_t index;
|
||||
ngx_int_t db;
|
||||
ngx_uint_t gzip_flag;
|
||||
+
|
||||
+ ngx_http_complex_value_t *complex_target; /* for redis_pass */
|
||||
} ngx_http_redis_loc_conf_t;
|
||||
|
||||
|
||||
@@ -44,6 +46,9 @@ static char *ngx_http_redis_merge_loc_co
|
||||
|
||||
static char *ngx_http_redis_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
+static ngx_http_upstream_srv_conf_t *
|
||||
+ ngx_http_redis_upstream_add(ngx_http_request_t *r, ngx_url_t *url);
|
||||
+
|
||||
|
||||
static ngx_conf_bitmask_t ngx_http_redis_next_upstream_masks[] = {
|
||||
{ ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
|
||||
@@ -185,11 +190,43 @@ ngx_http_redis_handler(ngx_http_request_
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
+ rlcf = ngx_http_get_module_loc_conf(r, ngx_http_redis_module);
|
||||
+ if (rlcf->complex_target) {
|
||||
+ ngx_str_t target;
|
||||
+ ngx_url_t url;
|
||||
+
|
||||
+ /* variables used in the redis_pass directive */
|
||||
+
|
||||
+ if (ngx_http_complex_value(r, rlcf->complex_target, &target)
|
||||
+ != NGX_OK)
|
||||
+ {
|
||||
+ return NGX_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ if (target.len == 0) {
|
||||
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
+ "handler: empty \"redis_pass\" target");
|
||||
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ url.host = target;
|
||||
+ url.port = 0;
|
||||
+ url.default_port = 6379;
|
||||
+ url.no_resolve = 1;
|
||||
+
|
||||
+ rlcf->upstream.upstream = ngx_http_redis_upstream_add(r, &url);
|
||||
+
|
||||
+ if (rlcf->upstream.upstream == NULL) {
|
||||
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
+ "redis: upstream \"%V\" not found", &target);
|
||||
+
|
||||
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
#if defined nginx_version && nginx_version >= 8011
|
||||
if (ngx_http_upstream_create(r) != NGX_OK) {
|
||||
#else
|
||||
- rlcf = ngx_http_get_module_loc_conf(r, ngx_http_redis_module);
|
||||
-
|
||||
u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));
|
||||
if (u == NULL) {
|
||||
#endif
|
||||
@@ -214,9 +251,7 @@ ngx_http_redis_handler(ngx_http_request_
|
||||
u->peer.log_error = NGX_ERROR_ERR;
|
||||
#endif
|
||||
|
||||
-#if defined nginx_version && nginx_version >= 8011
|
||||
- rlcf = ngx_http_get_module_loc_conf(r, ngx_http_redis_module);
|
||||
-#else
|
||||
+#if !defined(nginx_version) || nginx_version < 8011
|
||||
u->output.tag = (ngx_buf_tag_t) &ngx_http_redis_module;
|
||||
#endif
|
||||
|
||||
@@ -835,24 +870,15 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
|
||||
|
||||
ngx_str_t *value;
|
||||
ngx_url_t u;
|
||||
+ ngx_uint_t n;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
|
||||
+ ngx_http_compile_complex_value_t ccv;
|
||||
+
|
||||
if (rlcf->upstream.upstream) {
|
||||
return "is duplicate";
|
||||
}
|
||||
|
||||
- value = cf->args->elts;
|
||||
-
|
||||
- ngx_memzero(&u, sizeof(ngx_url_t));
|
||||
-
|
||||
- u.url = value[1];
|
||||
- u.no_resolve = 1;
|
||||
-
|
||||
- rlcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
|
||||
- if (rlcf->upstream.upstream == NULL) {
|
||||
- return NGX_CONF_ERROR;
|
||||
- }
|
||||
-
|
||||
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
||||
|
||||
clcf->handler = ngx_http_redis_handler;
|
||||
@@ -869,6 +895,41 @@ ngx_http_redis_pass(ngx_conf_t *cf, ngx_
|
||||
|
||||
rlcf->db = ngx_http_get_variable_index(cf, &ngx_http_redis_db);
|
||||
|
||||
+ value = cf->args->elts;
|
||||
+
|
||||
+ n = ngx_http_script_variables_count(&value[1]);
|
||||
+ if (n) {
|
||||
+ rlcf->complex_target = ngx_palloc(cf->pool,
|
||||
+ sizeof(ngx_http_complex_value_t));
|
||||
+
|
||||
+ if (rlcf->complex_target == NULL) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
||||
+ ccv.cf = cf;
|
||||
+ ccv.value = &value[1];
|
||||
+ ccv.complex_value = rlcf->complex_target;
|
||||
+
|
||||
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ return NGX_CONF_OK;
|
||||
+ }
|
||||
+
|
||||
+ rlcf->complex_target = NULL;
|
||||
+
|
||||
+ ngx_memzero(&u, sizeof(ngx_url_t));
|
||||
+
|
||||
+ u.url = value[1];
|
||||
+ u.no_resolve = 1;
|
||||
+
|
||||
+ rlcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
|
||||
+ if (rlcf->upstream.upstream == NULL) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
@@ -906,3 +967,41 @@ ngx_http_redis_add_variables(ngx_conf_t
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
+
|
||||
+
|
||||
+static ngx_http_upstream_srv_conf_t *
|
||||
+ngx_http_redis_upstream_add(ngx_http_request_t *r, ngx_url_t *url)
|
||||
+{
|
||||
+ ngx_http_upstream_main_conf_t *umcf;
|
||||
+ ngx_http_upstream_srv_conf_t **uscfp;
|
||||
+ ngx_uint_t i;
|
||||
+
|
||||
+ umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
||||
+
|
||||
+ uscfp = umcf->upstreams.elts;
|
||||
+
|
||||
+ for (i = 0; i < umcf->upstreams.nelts; i++) {
|
||||
+
|
||||
+ if (uscfp[i]->host.len != url->host.len
|
||||
+ || ngx_strncasecmp(uscfp[i]->host.data, url->host.data,
|
||||
+ url->host.len) != 0)
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (uscfp[i]->port != url->port) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (uscfp[i]->default_port
|
||||
+ && url->default_port
|
||||
+ && uscfp[i]->default_port != url->default_port)
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ return uscfp[i];
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
654
t/sanity.t
654
t/sanity.t
File diff suppressed because it is too large
Load Diff
@ -139,6 +139,10 @@ if [ "$answer" = "N" ]; then
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "$info_txt applying the run_posted_requests_in_resolver patch for nginx"
|
||||
patch -p1 < $root/patches/nginx-$main_ver-run_posted_requests_in_resolver.patch || exit 1
|
||||
echo
|
||||
|
||||
rm -f *.patch || exit 1
|
||||
|
||||
cd .. || exit 1
|
||||
@ -152,7 +156,7 @@ rm -rf no-pool-nginx-$ver
|
||||
|
||||
#################################
|
||||
|
||||
ver=0.42
|
||||
ver=0.44
|
||||
$root/util/get-tarball "http://github.com/agentzh/echo-nginx-module/tarball/v$ver" -O echo-nginx-module-$ver.tar.gz || exit 1
|
||||
tar -xzf echo-nginx-module-$ver.tar.gz || exit 1
|
||||
mv agentzh-echo-nginx-module-* echo-nginx-module-$ver || exit 1
|
||||
@ -208,7 +212,7 @@ mv chaoslawful-drizzle-nginx-module-* drizzle-nginx-module-$ver || exit 1
|
||||
|
||||
#################################
|
||||
|
||||
ver=0.7.16
|
||||
ver=0.7.18
|
||||
$root/util/get-tarball "http://github.com/chaoslawful/lua-nginx-module/tarball/v$ver" -O lua-nginx-module-$ver.tar.gz || exit 1
|
||||
tar -xzf lua-nginx-module-$ver.tar.gz || exit 1
|
||||
mv chaoslawful-lua-nginx-module-* ngx_lua-$ver || exit 1
|
||||
@ -277,6 +281,11 @@ $root/util/get-tarball "http://people.freebsd.org/~osa/ngx_http_redis-$ver.tar.g
|
||||
tar -xzf redis-nginx-module-$ver.tar.gz || exit 1
|
||||
mv ngx_http_redis-* redis-nginx-module-$ver || exit 1
|
||||
|
||||
cd redis-nginx-module-$ver
|
||||
echo "applying ngx_http_redis-$ver-variables_in_redis_pass.patch"
|
||||
patch -p1 < $root/patches/ngx_http_redis-$ver-variables_in_redis_pass.patch || exit 1
|
||||
cd ..
|
||||
|
||||
#################################
|
||||
|
||||
ver=1.0rc2
|
||||
@ -293,7 +302,7 @@ mv FRiCKLE-ngx_coolkit-* ngx_coolkit-$ver || exit 1
|
||||
|
||||
#################################
|
||||
|
||||
ver=0.09
|
||||
ver=0.10
|
||||
$root/util/get-tarball "http://github.com/agentzh/redis2-nginx-module/tarball/v$ver" -O redis2-nginx-module-$ver.tar.gz || exit 1
|
||||
tar -xzf redis2-nginx-module-$ver.tar.gz || exit 1
|
||||
mv agentzh-redis2-nginx-module-* redis2-nginx-module-$ver || exit 1
|
||||
@ -326,10 +335,12 @@ ver=2.0.1
|
||||
$root/util/get-tarball "http://luajit.org/download/LuaJIT-$ver.tar.gz" -O "LuaJIT-$ver.tar.gz" || exit 1
|
||||
tar -xzf LuaJIT-$ver.tar.gz || exit 1
|
||||
|
||||
#echo "$info_txt applying luajit-2.0.0-2ad9834d.patch for luajit 2.0.0"
|
||||
#cd LuaJIT-$ver || exit 1;
|
||||
#patch -p1 < $root/patches/luajit-2.0.0-2ad9834d.patch || exit 1
|
||||
#cd .. || exit 1
|
||||
echo "$info_txt applying luajit-$ver hotfix #1 patch for luajit $ver"
|
||||
$root/util/get-tarball http://luajit.org/download/v2.0.1_hotfix1.patch -O hotfix.patch
|
||||
cd LuaJIT-$ver || exit 1;
|
||||
patch -p1 < ../hotfix.patch || exit 1
|
||||
rm ../hotfix.patch
|
||||
cd .. || exit 1
|
||||
|
||||
#$root/util/get-tarball http://luajit.org/download/beta11_hotfix1.patch -O beta11_hotfix1.patch
|
||||
#patch -p1 < beta11_hotfix1.patch || exit 1
|
||||
@ -391,7 +402,7 @@ mv agentzh-lua-resty-mysql-* lua-resty-mysql-$ver || exit 1
|
||||
|
||||
#################################
|
||||
|
||||
ver=0.07
|
||||
ver=0.08
|
||||
$root/util/get-tarball "http://github.com/agentzh/lua-resty-upload/tarball/v$ver" -O "lua-resty-upload-$ver.tar.gz" || exit 1
|
||||
tar -xzf lua-resty-upload-$ver.tar.gz || exit 1
|
||||
mv agentzh-lua-resty-upload-* lua-resty-upload-$ver || exit 1
|
||||
|
Reference in New Issue
Block a user