Skip to content

Commit

Permalink
Stream phases (undeclare ngx_stream_mruby_handler in the case of less…
Browse files Browse the repository at this point in the history
  • Loading branch information
hfm committed Oct 11, 2016
1 parent 83d4acd commit b60f529
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/stream/ngx_stream_mruby_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ static ngx_int_t ngx_stream_mrb_run_conf(ngx_conf_t *cf, mrb_state *mrb, ngx_mrb
}
*/

#if (nginx_version < 1011005)
static ngx_int_t ngx_stream_mruby_handler(ngx_stream_session_t *s)
{
ngx_stream_mruby_srv_conf_t *mscf = ngx_stream_get_module_srv_conf(s, ngx_stream_mruby_module);
Expand All @@ -693,13 +694,26 @@ static ngx_int_t ngx_stream_mruby_handler(ngx_stream_session_t *s)
/* default NGX_DECLINED */
return ictx->stream_status;
}
#endif

/* set mruby_handler to access phase */
static ngx_int_t ngx_stream_mruby_init(ngx_conf_t *cf)
{
ngx_stream_core_main_conf_t *cmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_core_module);

#if (nginx_version < 1011005)
cmcf->access_handler = ngx_stream_mruby_handler;
#else
ngx_stream_handler_pt *h;
ngx_stream_core_main_conf_t *cmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_core_module);

h = ngx_array_push(&cmcf->phases[NGX_STREAM_ACCESS_PHASE].handlers);
if (h == NULL) {
return NGX_ERROR;
}

*h = ngx_stream_mruby_handler;
#endif

return NGX_OK;
}

0 comments on commit b60f529

Please sign in to comment.