Skip to content

Commit

Permalink
Merge pull request #1199 from wangfakang/master
Browse files Browse the repository at this point in the history
 Adapt *_upstream_tries directive.
  • Loading branch information
chobits authored Mar 6, 2019
2 parents 04b3191 + b41a6e3 commit bd7d4c7
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 59 deletions.
9 changes: 9 additions & 0 deletions src/http/modules/ngx_http_fastcgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ static ngx_command_t ngx_http_fastcgi_commands[] = {
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream_tries),
NULL },

#if (T_UPSTREAM_TRIES)
{ ngx_string("fastcgi_upstream_tries"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream_tries),
NULL },
#endif

{ ngx_string("fastcgi_next_upstream_timeout"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_msec_slot,
Expand Down
11 changes: 2 additions & 9 deletions src/http/modules/ngx_http_memcached_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static ngx_command_t ngx_http_memcached_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_memcached_loc_conf_t, upstream.upstream_tries),
offsetof(ngx_http_memcached_loc_conf_t, upstream.next_upstream_tries),
NULL },
#endif

Expand Down Expand Up @@ -613,16 +613,14 @@ ngx_http_memcached_create_loc_conf(ngx_conf_t *cf)
conf->upstream.local = NGX_CONF_UNSET_PTR;
conf->upstream.socket_keepalive = NGX_CONF_UNSET;
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;

conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC;

conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;

#if (T_UPSTREAM_TRIES)
conf->upstream.upstream_tries = NGX_CONF_UNSET_UINT;
#endif

/* the hardcoded values */
conf->upstream.cyclic_temp_file = 0;
Expand Down Expand Up @@ -688,11 +686,6 @@ ngx_http_memcached_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_OFF;
}

#if (T_UPSTREAM_TRIES)
ngx_conf_merge_uint_value(conf->upstream.upstream_tries,
prev->upstream.upstream_tries,
NGX_CONF_UNSET_UINT);
#endif

if (conf->upstream.upstream == NULL) {
conf->upstream.upstream = prev->upstream.upstream;
Expand Down
12 changes: 1 addition & 11 deletions src/http/modules/ngx_http_proxy_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ static ngx_command_t ngx_http_proxy_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_proxy_loc_conf_t, upstream.upstream_tries),
offsetof(ngx_http_proxy_loc_conf_t, upstream.next_upstream_tries),
NULL },
#endif

Expand Down Expand Up @@ -2864,10 +2864,6 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;

#if (T_UPSTREAM_TRIES)
conf->upstream.upstream_tries = NGX_CONF_UNSET_UINT;
#endif

conf->upstream.pass_request_headers = NGX_CONF_UNSET;
conf->upstream.pass_request_body = NGX_CONF_UNSET;

Expand Down Expand Up @@ -3106,12 +3102,6 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_OFF;
}

#if (T_UPSTREAM_TRIES)
ngx_conf_merge_uint_value(conf->upstream.upstream_tries,
prev->upstream.upstream_tries,
NGX_CONF_UNSET_UINT);
#endif

if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path,
prev->upstream.temp_path,
&ngx_http_proxy_temp_path)
Expand Down
14 changes: 2 additions & 12 deletions src/http/modules/ngx_http_scgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ static ngx_command_t ngx_http_scgi_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_scgi_loc_conf_t, upstream.upstream_tries),
offsetof(ngx_http_scgi_loc_conf_t, upstream.next_upstream_tries),
NULL },
#endif

Expand Down Expand Up @@ -1210,6 +1210,7 @@ ngx_http_scgi_create_loc_conf(ngx_conf_t *cf)
conf->upstream.store = NGX_CONF_UNSET;
conf->upstream.store_access = NGX_CONF_UNSET_UINT;
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;

conf->upstream.buffering = NGX_CONF_UNSET;
conf->upstream.request_buffering = NGX_CONF_UNSET;
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
Expand All @@ -1230,11 +1231,6 @@ ngx_http_scgi_create_loc_conf(ngx_conf_t *cf)
conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;

#if (T_UPSTREAM_TRIES)
conf->upstream.upstream_tries = NGX_CONF_UNSET_UINT;
#endif

conf->upstream.pass_request_headers = NGX_CONF_UNSET;
conf->upstream.pass_request_body = NGX_CONF_UNSET;

Expand Down Expand Up @@ -1448,12 +1444,6 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));

#if (T_UPSTREAM_TRIES)
ngx_conf_merge_uint_value(conf->upstream.upstream_tries,
prev->upstream.upstream_tries,
NGX_CONF_UNSET_UINT);
#endif

if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
|NGX_HTTP_UPSTREAM_FT_OFF;
Expand Down
14 changes: 2 additions & 12 deletions src/http/modules/ngx_http_uwsgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static ngx_command_t ngx_http_uwsgi_commands[] = {
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.upstream_tries),
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.next_upstream_tries),
NULL },
#endif

Expand Down Expand Up @@ -1423,6 +1423,7 @@ ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
conf->upstream.store = NGX_CONF_UNSET;
conf->upstream.store_access = NGX_CONF_UNSET_UINT;
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;

conf->upstream.buffering = NGX_CONF_UNSET;
conf->upstream.request_buffering = NGX_CONF_UNSET;
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
Expand All @@ -1443,11 +1444,6 @@ ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf)
conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;

#if (T_UPSTREAM_TRIES)
conf->upstream.upstream_tries = NGX_CONF_UNSET_UINT;
#endif

conf->upstream.pass_request_headers = NGX_CONF_UNSET;
conf->upstream.pass_request_body = NGX_CONF_UNSET;

Expand Down Expand Up @@ -1669,12 +1665,6 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|NGX_HTTP_UPSTREAM_FT_ERROR
|NGX_HTTP_UPSTREAM_FT_TIMEOUT));

#if (T_UPSTREAM_TRIES)
ngx_conf_merge_uint_value(conf->upstream.upstream_tries,
prev->upstream.upstream_tries,
NGX_CONF_UNSET_UINT);
#endif

if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
|NGX_HTTP_UPSTREAM_FT_OFF;
Expand Down
4 changes: 0 additions & 4 deletions src/http/ngx_http_core_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2435,10 +2435,6 @@ ngx_http_subrequest(ngx_http_request_t *r,
c = r->connection;
sr->connection = c;

#if (T_UPSTREAM_TRIES)
sr->us_tries = 1;
#endif

sr->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
if (sr->ctx == NULL) {
return NGX_ERROR;
Expand Down
4 changes: 0 additions & 4 deletions src/http/ngx_http_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,6 @@ ngx_http_alloc_request(ngx_connection_t *c)
r->main = r;
r->count = 1;

#if (T_UPSTREAM_TRIES)
r->us_tries = 1;
#endif

#if (T_NGX_RET_CACHE)
{
struct timeval tv;
Expand Down
4 changes: 0 additions & 4 deletions src/http/ngx_http_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,6 @@ struct ngx_http_request_s {

ngx_uint_t err_status;

#if (T_UPSTREAM_TRIES)
ngx_uint_t us_tries;
#endif

ngx_http_connection_t *http_connection;
ngx_http_v2_stream_t *stream;

Expand Down
3 changes: 0 additions & 3 deletions src/http/ngx_http_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ typedef struct {

ngx_uint_t ignore_headers;
ngx_uint_t next_upstream;
#if (T_UPSTREAM_TRIES)
ngx_uint_t upstream_tries;
#endif
ngx_uint_t store_access;
ngx_uint_t next_upstream_tries;
ngx_flag_t buffering;
Expand Down

0 comments on commit bd7d4c7

Please sign in to comment.