]> git.kaiwu.me - njs.git/commitdiff
Modules: separating different init worker components.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 15 May 2025 01:00:23 +0000 (18:00 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 22 May 2025 23:54:29 +0000 (16:54 -0700)
nginx/ngx_http_js_module.c
nginx/ngx_stream_js_module.c

index 40bb83a515cb1c878508097353223a4190f03ccc..3b493bd162ca7f0bfbab2f8daaf97e9bd2ee3855 100644 (file)
@@ -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)
 {
index 0e022eb00b199895375a7f68586dcd8c0f8d300b..bc653a5b6bb6487054522e2a45faba3694464975 100644 (file)
@@ -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)
 {