[nginx] Removed "ch" argument from ngx_pass_open_channel().

Ruslan Ermilov ru at nginx.com
Thu Mar 11 07:20:44 UTC 2021


details:   https://hg.nginx.org/nginx/rev/0215ec9aaa8a
branches:  
changeset: 7802:0215ec9aaa8a
user:      Ruslan Ermilov <ru at nginx.com>
date:      Thu Mar 11 09:58:45 2021 +0300
description:
Removed "ch" argument from ngx_pass_open_channel().

diffstat:

 src/os/unix/ngx_process_cycle.c |  59 +++++++++++++---------------------------
 1 files changed, 19 insertions(+), 40 deletions(-)

diffs (130 lines):

diff -r 777373b5a169 -r 0215ec9aaa8a src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c	Thu Mar 11 04:46:26 2021 +0300
+++ b/src/os/unix/ngx_process_cycle.c	Thu Mar 11 09:58:45 2021 +0300
@@ -15,7 +15,7 @@ static void ngx_start_worker_processes(n
     ngx_int_t type);
 static void ngx_start_cache_manager_processes(ngx_cycle_t *cycle,
     ngx_uint_t respawn);
-static void ngx_pass_open_channel(ngx_cycle_t *cycle, ngx_channel_t *ch);
+static void ngx_pass_open_channel(ngx_cycle_t *cycle);
 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
 static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
 static void ngx_master_process_exit(ngx_cycle_t *cycle);
@@ -335,25 +335,16 @@ ngx_single_process_cycle(ngx_cycle_t *cy
 static void
 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
 {
-    ngx_int_t      i;
-    ngx_channel_t  ch;
+    ngx_int_t  i;
 
     ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes");
 
-    ngx_memzero(&ch, sizeof(ngx_channel_t));
-
-    ch.command = NGX_CMD_OPEN_CHANNEL;
-
     for (i = 0; i < n; i++) {
 
         ngx_spawn_process(cycle, ngx_worker_process_cycle,
                           (void *) (intptr_t) i, "worker process", type);
 
-        ch.pid = ngx_processes[ngx_process_slot].pid;
-        ch.slot = ngx_process_slot;
-        ch.fd = ngx_processes[ngx_process_slot].channel[0];
-
-        ngx_pass_open_channel(cycle, &ch);
+        ngx_pass_open_channel(cycle);
     }
 }
 
@@ -361,9 +352,8 @@ ngx_start_worker_processes(ngx_cycle_t *
 static void
 ngx_start_cache_manager_processes(ngx_cycle_t *cycle, ngx_uint_t respawn)
 {
-    ngx_uint_t       i, manager, loader;
-    ngx_path_t     **path;
-    ngx_channel_t    ch;
+    ngx_uint_t    i, manager, loader;
+    ngx_path_t  **path;
 
     manager = 0;
     loader = 0;
@@ -388,14 +378,7 @@ ngx_start_cache_manager_processes(ngx_cy
                       &ngx_cache_manager_ctx, "cache manager process",
                       respawn ? NGX_PROCESS_JUST_RESPAWN : NGX_PROCESS_RESPAWN);
 
-    ngx_memzero(&ch, sizeof(ngx_channel_t));
-
-    ch.command = NGX_CMD_OPEN_CHANNEL;
-    ch.pid = ngx_processes[ngx_process_slot].pid;
-    ch.slot = ngx_process_slot;
-    ch.fd = ngx_processes[ngx_process_slot].channel[0];
-
-    ngx_pass_open_channel(cycle, &ch);
+    ngx_pass_open_channel(cycle);
 
     if (loader == 0) {
         return;
@@ -405,20 +388,21 @@ ngx_start_cache_manager_processes(ngx_cy
                       &ngx_cache_loader_ctx, "cache loader process",
                       respawn ? NGX_PROCESS_JUST_SPAWN : NGX_PROCESS_NORESPAWN);
 
+    ngx_pass_open_channel(cycle);
+}
+
+
+static void
+ngx_pass_open_channel(ngx_cycle_t *cycle)
+{
+    ngx_int_t      i;
+    ngx_channel_t  ch;
+
     ch.command = NGX_CMD_OPEN_CHANNEL;
     ch.pid = ngx_processes[ngx_process_slot].pid;
     ch.slot = ngx_process_slot;
     ch.fd = ngx_processes[ngx_process_slot].channel[0];
 
-    ngx_pass_open_channel(cycle, &ch);
-}
-
-
-static void
-ngx_pass_open_channel(ngx_cycle_t *cycle, ngx_channel_t *ch)
-{
-    ngx_int_t  i;
-
     for (i = 0; i < ngx_last_process; i++) {
 
         if (i == ngx_process_slot
@@ -430,14 +414,14 @@ ngx_pass_open_channel(ngx_cycle_t *cycle
 
         ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
                       "pass channel s:%i pid:%P fd:%d to s:%i pid:%P fd:%d",
-                      ch->slot, ch->pid, ch->fd,
+                      ch.slot, ch.pid, ch.fd,
                       i, ngx_processes[i].pid,
                       ngx_processes[i].channel[0]);
 
         /* TODO: NGX_AGAIN */
 
         ngx_write_channel(ngx_processes[i].channel[0],
-                          ch, sizeof(ngx_channel_t), cycle->log);
+                          &ch, sizeof(ngx_channel_t), cycle->log);
     }
 }
 
@@ -621,12 +605,7 @@ ngx_reap_children(ngx_cycle_t *cycle)
                 }
 
 
-                ch.command = NGX_CMD_OPEN_CHANNEL;
-                ch.pid = ngx_processes[ngx_process_slot].pid;
-                ch.slot = ngx_process_slot;
-                ch.fd = ngx_processes[ngx_process_slot].channel[0];
-
-                ngx_pass_open_channel(cycle, &ch);
+                ngx_pass_open_channel(cycle);
 
                 live = 1;
 


More information about the nginx-devel mailing list