-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathngx_process.patch
33 lines (27 loc) · 905 Bytes
/
ngx_process.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--- old/nginx-1.21.4/src/os/unix/ngx_process.c 2021-11-02 22:49:22.000000000 +0800
+++ new/nginx-1.21.4/src/os/unix/ngx_process.c 2022-05-25 18:57:17.649674515 +0800
@@ -82,7 +82,7 @@
{ 0, NULL, "", NULL }
};
-
+int ngx_worker_index = -1;
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -182,18 +182,20 @@
ngx_process_slot = s;
-
+ ngx_worker_index++;
pid = fork();
switch (pid) {
case -1:
+ ngx_worker_index--;
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"fork() failed while spawning \"%s\"", name);
ngx_close_channel(ngx_processes[s].channel, cycle->log);
return NGX_INVALID_PID;
case 0:
+ init_worker(ngx_worker_index);
ngx_parent = ngx_pid;
ngx_pid = ngx_getpid();
proc(cycle, data);