@@ -134,13 +134,13 @@ static u_char* ngx_http_c_func_strdup_with_p(ngx_pool_t *pool, const char *src,
134134
135135// static ngx_int_t ngx_http_c_func_get_resp_var(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data);
136136// static void ngx_http_c_func_set_resp_var_with_r(ngx_http_request_t *r, ngx_http_c_func_ctx_t *ctx, const char* resp_content, size_t resp_len);
137- #if (nginx_version > 1013003 )
137+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
138138static void ngx_http_c_func_output_filter (ngx_http_request_t * r );
139139#else
140140static ngx_int_t ngx_http_c_func_output_filter (ngx_http_request_t * r );
141141#endif
142142
143- #if (NGX_THREADS && nginx_version > 1013003 )
143+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
144144static void ngx_http_c_func_after_process (ngx_event_t * ev );
145145static void ngx_http_c_func_process_t_handler (void * data , ngx_log_t * log );
146146#endif
@@ -549,13 +549,8 @@ ngx_http_c_func_post_configuration(ngx_conf_t *cf) {
549549 * h = ngx_http_c_func_rewrite_handler ;
550550
551551 /***Enable pre content phase for apps concurrent processing request layer, NGX_DONE and wait for finalize request ***/
552- #if (nginx_version > 1013003 )
552+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
553553 h = ngx_array_push (& cmcf -> phases [NGX_HTTP_PRECONTENT_PHASE ].handlers );
554- if (h == NULL ) {
555- return NGX_ERROR ;
556- }
557-
558- * h = ngx_http_c_func_precontent_handler ;
559554#else
560555 /**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,
561556 then it will be last to called as it is reverse order
@@ -571,10 +566,14 @@ ngx_http_c_func_post_configuration(ngx_conf_t *cf) {
571566 // h[i + 1] = h[i];
572567 // }
573568
574- // h[0] = ngx_http_c_func_precontent_handler;
575- * h = ngx_http_c_func_precontent_handler ;
576-
569+ // h[0] = ngx_http_c_func_precontent_handler;
577570#endif
571+
572+ if (h == NULL ) {
573+ return NGX_ERROR ;
574+ }
575+
576+ * h = ngx_http_c_func_precontent_handler ;
578577
579578 }
580579
@@ -627,7 +626,7 @@ ngx_http_c_func_module_init(ngx_cycle_t *cycle) {
627626
628627 cscfp = cmcf -> servers .elts ;
629628
630- #if (NGX_THREADS && nginx_version > 1013003 )
629+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
631630 ngx_log_error (NGX_LOG_NOTICE , cycle -> log , 0 , " enabled aio threads for c-function module " );
632631#endif
633632
@@ -941,7 +940,7 @@ ngx_http_c_func_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) {
941940 return NGX_CONF_OK ;
942941}
943942
944- #if (NGX_THREADS && nginx_version > 1013003 )
943+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
945944static void
946945ngx_http_c_func_process_t_handler (void * data , ngx_log_t * log )
947946{
@@ -1024,7 +1023,7 @@ ngx_http_c_func_precontent_handler(ngx_http_request_t *r) {
10241023 if (internal_ctx -> aio_processing ) {
10251024 return NGX_AGAIN ;
10261025 } else {
1027- #if (nginx_version > 1013003 )
1026+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
10281027 ngx_http_c_func_output_filter (r );
10291028 return NGX_DONE ;
10301029#else
@@ -1136,7 +1135,7 @@ ngx_http_c_func_precontent_handler(ngx_http_request_t *r) {
11361135 new_ctx -> req_body_len = 0 ;
11371136 }
11381137
1139- #if (NGX_THREADS && nginx_version > 1013003 )
1138+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
11401139 internal_ctx -> aio_processing = 1 ;
11411140 ngx_thread_pool_t * tp ;
11421141 ngx_http_core_loc_conf_t * clcf ;
@@ -1167,7 +1166,7 @@ ngx_http_c_func_precontent_handler(ngx_http_request_t *r) {
11671166 ngx_log_error (NGX_LOG_WARN , r -> connection -> log , 0 , " nginx c function with nginx 1.13.3 and below is running single thread only, upgrade to nginx > 1.13.3 for concurrent request" );
11681167#endif
11691168 lcf -> _handler (new_ctx );
1170- #if (nginx_version > 1013003 )
1169+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
11711170 ngx_http_c_func_output_filter (r );
11721171 return NGX_DONE ;
11731172#else
@@ -1755,7 +1754,7 @@ ngx_http_c_func_write_resp(
17551754 );
17561755}
17571756
1758- #if (nginx_version > 1013003 )
1757+ #if (NGX_THREADS ) && ( nginx_version > 1013003 )
17591758static void
17601759ngx_http_c_func_output_filter (
17611760 ngx_http_request_t * r
0 commit comments