@@ -205,9 +205,6 @@ static ngx_int_t ngx_http_upstream_init_polaris_peer(ngx_http_request_t *r,
205205 r->upstream ->peer .get = ngx_http_upstream_get_polaris_peer;
206206 r->upstream ->peer .free = ngx_http_upstream_free_polaris_peer;
207207
208- if (dcf->max_tries != NGX_CONF_UNSET_UINT) {
209- r->upstream ->peer .tries = dcf->max_tries ;
210- }
211208 // control the retry times >= 2.
212209 if (r->upstream ->peer .tries < 2 ) {
213210 r->upstream ->peer .tries = 2 ;
@@ -227,7 +224,6 @@ static ngx_int_t ngx_http_upstream_init_polaris_peer(ngx_http_request_t *r,
227224
228225 memset (ctx, 0 , sizeof (ngx_http_upstream_polaris_ctx_t ));
229226 ngx_http_set_ctx (r, ctx, ngx_http_upstream_polaris_module);
230- dp->ctx = ctx;
231227 }
232228
233229 if (polaris_init_params (dcf, r, ctx) != NGX_OK) {
@@ -251,7 +247,8 @@ static ngx_int_t ngx_http_upstream_get_polaris_peer(ngx_peer_connection_t *pc, v
251247 pc->cached = 0 ;
252248 pc->connection = NULL ;
253249
254- ngx_http_upstream_polaris_ctx_t *ctx = bp->ctx ;
250+ ngx_http_upstream_polaris_ctx_t *ctx = reinterpret_cast <ngx_http_upstream_polaris_ctx_t *>(
251+ ngx_http_get_module_ctx (r, ngx_http_upstream_polaris_module));
255252
256253 int ret = polaris_get_addr (ctx);
257254
@@ -283,7 +280,8 @@ static void ngx_http_upstream_free_polaris_peer(ngx_peer_connection_t *pc, void
283280
284281 ngx_log_debug (NGX_LOG_DEBUG_HTTP, pc->log , 0 , " free polaris peer state:%d" , state);
285282
286- ngx_http_upstream_polaris_ctx_t *ctx = bp->ctx ;
283+ ngx_http_upstream_polaris_ctx_t *ctx = reinterpret_cast <ngx_http_upstream_polaris_ctx_t *>(
284+ ngx_http_get_module_ctx (bp->request , ngx_http_upstream_polaris_module));
287285
288286 ngx_log_debug (NGX_LOG_DEBUG_HTTP, pc->log , 0 , " free polaris peer ret status code: %d" ,
289287 bp->request ->headers_out .status );
@@ -343,7 +341,6 @@ static void *ngx_http_upstream_polaris_create_conf(ngx_conf_t *cf) {
343341 conf->polaris_metadata_route_enabled = false ;
344342 ngx_str_set (&conf->polaris_fail_status_list , " " );
345343 conf->polaris_fail_status_report_enabled = false ;
346- conf->max_tries = NGX_CONF_UNSET_UINT;
347344
348345 return conf;
349346}
@@ -588,20 +585,6 @@ static char *ngx_http_upstream_polaris_set_handler(ngx_conf_t *cf, ngx_command_t
588585
589586 continue ;
590587 }
591-
592- if (ngx_strncmp (value[i].data , " max_tries=" , 10 ) == 0 ) {
593- ngx_str_t s = {value[i].len - 10 , &value[i].data [10 ]};
594-
595- ngx_int_t max_tries = ngx_atoi (s.data , s.len );
596- if (max_tries < 1 || max_tries > 256 ) {
597- ngx_conf_log_error (NGX_LOG_ERR, cf, 0 ,
598- " dcf->max_tries:%d invalid, only valid in (1-256)" ,
599- max_tries);
600- return const_cast <char *>(" invalid polaris max_tries" );
601- }
602- dcf->max_tries = max_tries;
603- continue ;
604- }
605588 }
606589
607590 dcf->enabled = true ;
@@ -663,10 +646,10 @@ static char *ngx_http_upstream_polaris_set_handler(ngx_conf_t *cf, ngx_command_t
663646 ngx_conf_log_error (
664647 NGX_LOG_NOTICE, cf, 0 ,
665648 " init service_namespace:%s, service_name:%s, timeout: %.2f, mode: %d, "
666- " key: %s, dr: %d, mr_mode: %d, fail_status: %s, max_tries: %d " ,
649+ " key: %s, dr: %d, mr_mode: %d, fail_status: %s" ,
667650 dcf->polaris_service_namespace .data , dcf->polaris_service_name .data , dcf->polaris_timeout ,
668651 dcf->polaris_lb_mode , dcf->polaris_lb_key .data , dcf->polaris_dynamic_route_enabled ,
669- dcf->metadata_route_failover_mode , dcf->polaris_fail_status_list .data , dcf-> max_tries );
652+ dcf->metadata_route_failover_mode , dcf->polaris_fail_status_list .data );
670653
671654 return NGX_CONF_OK;
672655}
0 commit comments