Skip to content

Commit b2dd320

Browse files
committed
update support authorization phase for nginx version lower than 1.13.3
1 parent 2271a96 commit b2dd320

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/ngx_http_c_func_module.c

+18-3
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,29 @@ ngx_http_c_func_post_configuration(ngx_conf_t *cf) {
523523
/***Enable pre content phase for apps concurrent processing request layer, NGX_DONE and wait for finalize request ***/
524524
#if (nginx_version > 1013003)
525525
h = ngx_array_push(&cmcf->phases[NGX_HTTP_PRECONTENT_PHASE].handlers);
526-
#else /**Access Phase is the only last phase for multi thread**/
527-
h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
528-
#endif
529526
if (h == NULL) {
530527
return NGX_ERROR;
531528
}
532529

533530
*h = ngx_http_c_func_precontent_handler;
531+
#else
532+
/**Access Phase is the only last phase for multi thread, we need to mimic to trick nginx c function access phase at first to register,
533+
then it will be last to called as it is reverse order
534+
**/
535+
h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
536+
if (h == NULL) {
537+
return NGX_ERROR;
538+
}
539+
540+
h = cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers.elts;
541+
ngx_uint_t i;
542+
for (i = 0; i < cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers.nelts - 1; i++) {
543+
h[i + 1] = h[i];
544+
}
545+
546+
h[0] = ngx_http_c_func_precontent_handler;
547+
#endif
548+
534549
}
535550

536551
/*** Default Init for shm with 1M if pool is empty***/

0 commit comments

Comments
 (0)