Skip to content

Commit

Permalink
Merge pull request alibaba#499 from InfoHunter/dyn-dns
Browse files Browse the repository at this point in the history
Bugfix: in ngx_http_upstream_dynamic_module
  • Loading branch information
yaoweibin committed Jul 31, 2014
2 parents 6f8afb6 + 8c28f34 commit f4055b6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/http/modules/ngx_http_upstream_dynamic_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ ngx_http_upstream_get_dynamic_peer(ngx_peer_connection_t *pc, void *data)

if (pc->resolved == NGX_HTTP_UPSTREAM_DR_FAILED) {

failed:
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
"resolve failed! fallback: %ui", dscf->fallback);

Expand All @@ -364,7 +363,26 @@ ngx_http_upstream_get_dynamic_peer(ngx_peer_connection_t *pc, void *data)
if (dscf->fail_check
&& (ngx_time() - dscf->fail_check < dscf->fail_timeout))
{
goto failed;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
"in fail timeout period, fallback: %ui", dscf->fallback);

switch (dscf->fallback) {

case NGX_HTTP_UPSTREAM_DYN_RESOLVE_STALE:
return bp->original_get_peer(pc, bp->data);

case NGX_HTTP_UPSTREAM_DYN_RESOLVE_SHUTDOWN:
ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
return NGX_YIELD;

default:
/* default fallback action: check next upstream, still need
* to get peer in fail timeout period
*/
return bp->original_get_peer(pc, bp->data);
}

return NGX_DECLINED;
}

/* NGX_HTTP_UPSTREAM_DYN_RESOLVE_INIT, ask balancer */
Expand Down

0 comments on commit f4055b6

Please sign in to comment.