@@ -205,9 +205,6 @@ static ngx_int_t ngx_http_upstream_init_polaris_peer(ngx_http_request_t *r,
205
205
r->upstream ->peer .get = ngx_http_upstream_get_polaris_peer;
206
206
r->upstream ->peer .free = ngx_http_upstream_free_polaris_peer;
207
207
208
- if (dcf->max_tries != NGX_CONF_UNSET_UINT) {
209
- r->upstream ->peer .tries = dcf->max_tries ;
210
- }
211
208
// control the retry times >= 2.
212
209
if (r->upstream ->peer .tries < 2 ) {
213
210
r->upstream ->peer .tries = 2 ;
@@ -227,7 +224,6 @@ static ngx_int_t ngx_http_upstream_init_polaris_peer(ngx_http_request_t *r,
227
224
228
225
memset (ctx, 0 , sizeof (ngx_http_upstream_polaris_ctx_t ));
229
226
ngx_http_set_ctx (r, ctx, ngx_http_upstream_polaris_module);
230
- dp->ctx = ctx;
231
227
}
232
228
233
229
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
251
247
pc->cached = 0 ;
252
248
pc->connection = NULL ;
253
249
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));
255
252
256
253
int ret = polaris_get_addr (ctx);
257
254
@@ -283,7 +280,8 @@ static void ngx_http_upstream_free_polaris_peer(ngx_peer_connection_t *pc, void
283
280
284
281
ngx_log_debug (NGX_LOG_DEBUG_HTTP, pc->log , 0 , " free polaris peer state:%d" , state);
285
282
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));
287
285
288
286
ngx_log_debug (NGX_LOG_DEBUG_HTTP, pc->log , 0 , " free polaris peer ret status code: %d" ,
289
287
bp->request ->headers_out .status );
@@ -343,7 +341,6 @@ static void *ngx_http_upstream_polaris_create_conf(ngx_conf_t *cf) {
343
341
conf->polaris_metadata_route_enabled = false ;
344
342
ngx_str_set (&conf->polaris_fail_status_list , " " );
345
343
conf->polaris_fail_status_report_enabled = false ;
346
- conf->max_tries = NGX_CONF_UNSET_UINT;
347
344
348
345
return conf;
349
346
}
@@ -588,20 +585,6 @@ static char *ngx_http_upstream_polaris_set_handler(ngx_conf_t *cf, ngx_command_t
588
585
589
586
continue ;
590
587
}
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
- }
605
588
}
606
589
607
590
dcf->enabled = true ;
@@ -663,10 +646,10 @@ static char *ngx_http_upstream_polaris_set_handler(ngx_conf_t *cf, ngx_command_t
663
646
ngx_conf_log_error (
664
647
NGX_LOG_NOTICE, cf, 0 ,
665
648
" 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" ,
667
650
dcf->polaris_service_namespace .data , dcf->polaris_service_name .data , dcf->polaris_timeout ,
668
651
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 );
670
653
671
654
return NGX_CONF_OK;
672
655
}
0 commit comments