changeset 2556:8cc5011c3f73

Modules: separating different init worker components.
author Dmitry Volyntsev <xeioex@nginx.com>
date Wed, 14 May 2025 18:00:23 -0700
parents 502f52bb0f6c
children c042da9331ca
files nginx/ngx_http_js_module.c nginx/ngx_stream_js_module.c
diffstat 2 files changed, 58 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/nginx/ngx_http_js_module.c	Mon May 19 18:53:00 2025 -0700
+++ b/nginx/ngx_http_js_module.c	Wed May 14 18:00:23 2025 -0700
@@ -7684,21 +7684,12 @@
 
 
 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 @@
 }
 
 
+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)
 {
--- a/nginx/ngx_stream_js_module.c	Mon May 19 18:53:00 2025 -0700
+++ b/nginx/ngx_stream_js_module.c	Wed May 14 18:00:23 2025 -0700
@@ -3192,21 +3192,12 @@
 
 
 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;
-    }
-
-    jmcf = ngx_stream_cycle_get_module_main_conf(cycle, ngx_stream_js_module);
-
-    if (jmcf == NULL || jmcf->periodics == NULL) {
+    ngx_uint_t          i;
+    ngx_js_periodic_t  *periodics;
+
+    if (jmcf->periodics == NULL) {
         return NGX_OK;
     }
 
@@ -3234,6 +3225,31 @@
 }
 
 
+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)
 {