Skip to content

Commit fcedd39

Browse files
committed
2 parents 8fe47fd + c3c61b1 commit fcedd39

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/c/ngx_http_clojure_module.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,13 +894,19 @@ static ngx_int_t ngx_http_clojure_module_init(ngx_cycle_t *cycle) {
894894

895895
ngx_core_conf_t *ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
896896
ngx_http_conf_ctx_t *ctx = (ngx_http_conf_ctx_t *)ngx_get_conf(cycle->conf_ctx, ngx_http_module);
897-
ngx_http_clojure_main_conf_t *mcf = ctx->main_conf[ngx_http_clojure_module.ctx_index];
897+
ngx_http_clojure_main_conf_t *mcf;
898+
898899
#if !(NGX_WIN32)
899900
ngx_uint_t cl = 8;
900901
ngx_uint_t ssize = 0;
901902
#endif
902903
ngx_http_clojure_global_cycle = cycle;
903904

905+
if (ctx == NULL) {
906+
// No HTTP block in config
907+
return NGX_OK;
908+
}
909+
mcf = ctx->main_conf[ngx_http_clojure_module.ctx_index];
904910

905911
if (mcf->jvm_path.len == NGX_CONF_UNSET_SIZE) {
906912
return NGX_OK;
@@ -1022,6 +1028,10 @@ static ngx_int_t ngx_http_clojure_quit_master(ngx_cycle_t *cycle) {
10221028
static void ngx_http_clojure_process_exit(ngx_cycle_t *cycle) {
10231029
ngx_http_clojure_main_conf_t *mcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_clojure_module);
10241030

1031+
if (mcf == NULL) {
1032+
return;
1033+
}
1034+
10251035
if (mcf->jvm_disable_all) {
10261036
return;
10271037
}
@@ -1122,12 +1132,21 @@ static ngx_int_t ngx_http_clojure_init_locations_handlers(ngx_http_core_main_con
11221132
static ngx_int_t ngx_http_clojure_process_init(ngx_cycle_t *cycle) {
11231133
ngx_http_conf_ctx_t *ctx = (ngx_http_conf_ctx_t *)ngx_get_conf(cycle->conf_ctx, ngx_http_module);
11241134
ngx_int_t rc = 0;
1125-
ngx_http_core_main_conf_t *cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
1126-
ngx_http_core_srv_conf_t *cscf = ctx->srv_conf[ngx_http_core_module.ctx_index];
1127-
ngx_http_clojure_main_conf_t *mcf = ctx->main_conf[ngx_http_clojure_module.ctx_index];
1135+
1136+
ngx_http_core_main_conf_t *cmcf;
1137+
ngx_http_core_srv_conf_t *cscf;
1138+
ngx_http_clojure_main_conf_t *mcf;
11281139
ngx_core_conf_t *ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
11291140
ngx_int_t jvm_num = 0;
11301141

1142+
if (ctx == NULL) {
1143+
// No HTTP block in config
1144+
return NGX_OK;
1145+
}
1146+
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
1147+
cscf = ctx->srv_conf[ngx_http_core_module.ctx_index];
1148+
mcf = ctx->main_conf[ngx_http_clojure_module.ctx_index];
1149+
11311150
/*Fix issue #64 about proxy cache manger process
11321151
* We won't initialize jvm unless the current process is worker process or single process*/
11331152
if (ngx_process != NGX_PROCESS_WORKER && ngx_process != NGX_PROCESS_SINGLE) {

0 commit comments

Comments
 (0)