details:   
https://github.com/nginx/njs/commit/c7128880915d7201db1d2bc05baa5ba5e1287ce6
branches:  master
commit:    c7128880915d7201db1d2bc05baa5ba5e1287ce6
user:      Dmitry Volyntsev <xei...@nginx.com>
date:      Wed, 14 May 2025 18:00:23 -0700
description:
Modules: separating different init worker components.


---
 nginx/ngx_http_js_module.c   | 38 +++++++++++++++++++++++++++-----------
 nginx/ngx_stream_js_module.c | 42 +++++++++++++++++++++++++++++-------------
 2 files changed, 56 insertions(+), 24 deletions(-)

diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c
index 40bb83a5..3b493bd1 100644
--- a/nginx/ngx_http_js_module.c
+++ b/nginx/ngx_http_js_module.c
@@ -7684,21 +7684,12 @@ ngx_http_js_init(ngx_conf_t *cf)
 
 
 static ngx_int_t
-ngx_http_js_init_worker(ngx_cycle_t *cycle)
+ngx_http_js_init_worker_periodics(ngx_js_main_conf_t *jmcf)
 {
     ngx_uint_t           i;
     ngx_js_periodic_t   *periodics;
-    ngx_js_main_conf_t  *jmcf;
-
-    if ((ngx_process != NGX_PROCESS_WORKER)
-        && ngx_process != NGX_PROCESS_SINGLE)
-    {
-        return NGX_OK;
-    }
-
-    jmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_js_module);
 
-    if (jmcf == NULL || jmcf->periodics == NULL) {
+    if (jmcf->periodics == NULL) {
         return NGX_OK;
     }
 
@@ -7726,6 +7717,31 @@ ngx_http_js_init_worker(ngx_cycle_t *cycle)
 }
 
 
+static ngx_int_t
+ngx_http_js_init_worker(ngx_cycle_t *cycle)
+{
+    ngx_js_main_conf_t  *jmcf;
+
+    if ((ngx_process != NGX_PROCESS_WORKER)
+        && ngx_process != NGX_PROCESS_SINGLE)
+    {
+        return NGX_OK;
+    }
+
+    jmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_js_module);
+
+    if (jmcf == NULL) {
+        return NGX_OK;
+    }
+
+    if (ngx_http_js_init_worker_periodics(jmcf) != NGX_OK) {
+        return NGX_ERROR;
+    }
+
+    return NGX_OK;
+}
+
+
 static char *
 ngx_http_js_periodic(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c
index 0e022eb0..bc653a5b 100644
--- a/nginx/ngx_stream_js_module.c
+++ b/nginx/ngx_stream_js_module.c
@@ -3192,21 +3192,12 @@ ngx_stream_js_periodic_init(ngx_js_periodic_t *periodic)
 
 
 static ngx_int_t
-ngx_stream_js_init_worker(ngx_cycle_t *cycle)
+ngx_stream_js_init_worker_periodics(ngx_js_main_conf_t *jmcf)
 {
-    ngx_uint_t           i;
-    ngx_js_periodic_t   *periodics;
-    ngx_js_main_conf_t  *jmcf;
-
-    if ((ngx_process != NGX_PROCESS_WORKER)
-        && ngx_process != NGX_PROCESS_SINGLE)
-    {
-        return NGX_OK;
-    }
+    ngx_uint_t          i;
+    ngx_js_periodic_t  *periodics;
 
-    jmcf = ngx_stream_cycle_get_module_main_conf(cycle, ngx_stream_js_module);
-
-    if (jmcf == NULL || jmcf->periodics == NULL) {
+    if (jmcf->periodics == NULL) {
         return NGX_OK;
     }
 
@@ -3234,6 +3225,31 @@ ngx_stream_js_init_worker(ngx_cycle_t *cycle)
 }
 
 
+static ngx_int_t
+ngx_stream_js_init_worker(ngx_cycle_t *cycle)
+{
+    ngx_js_main_conf_t  *jmcf;
+
+    if ((ngx_process != NGX_PROCESS_WORKER)
+        && ngx_process != NGX_PROCESS_SINGLE)
+    {
+        return NGX_OK;
+    }
+
+    jmcf = ngx_stream_cycle_get_module_main_conf(cycle, ngx_stream_js_module);
+
+    if (jmcf == NULL) {
+        return NGX_OK;
+    }
+
+    if (ngx_stream_js_init_worker_periodics(jmcf) != NGX_OK) {
+        return NGX_ERROR;
+    }
+
+    return NGX_OK;
+}
+
+
 static char *
 ngx_stream_js_periodic(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to