Skip to content

Commit 832cdf4

Browse files
committed
fix segment fault when upstream has no balancer
1 parent 7c26ee3 commit 832cdf4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/c/ngx_http_clojure_module.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,8 +1278,10 @@ static ngx_int_t ngx_http_clojure_init_upstreams_load_balancer_helper(ngx_http_u
12781278
ngx_http_clojure_srv_conf_t *scf;
12791279
ngx_uint_t s;
12801280
for (s = 0; s < umcf->upstreams.nelts; s++) {
1281-
scf = uscf[s]->srv_conf[ngx_http_clojure_module.ctx_index];
1282-
ngx_http_clojure_init_handler_script(scf, NGX_HTTP_LOAD_BALANCE_PHASE, load_balancer);
1281+
if (uscf[s]->srv_conf != NULL) {
1282+
scf = uscf[s]->srv_conf[ngx_http_clojure_module.ctx_index];
1283+
ngx_http_clojure_init_handler_script(scf, NGX_HTTP_LOAD_BALANCE_PHASE, load_balancer);
1284+
}
12831285
}
12841286
return NGX_OK;
12851287
}
@@ -1402,7 +1404,7 @@ static ngx_int_t ngx_http_clojure_process_init(ngx_cycle_t *cycle) {
14021404
return NGX_ERROR;
14031405
}
14041406

1405-
if (ngx_http_clojure_init_upstreams_load_balancer_helper(umcf) != NGX_OK) {
1407+
if (mcf->enable_load_balancer && ngx_http_clojure_init_upstreams_load_balancer_helper(umcf) != NGX_OK) {
14061408
return NGX_ERROR;
14071409
}
14081410

0 commit comments

Comments
 (0)