feature: add proc_exit_handler.

pull/971/merge
lijunlong 3 months ago
parent 347c47c784
commit 27303d2fd0

@ -0,0 +1,80 @@
commit 29cafd35fb2b7cff759fb4c9b84fa4600875321f
Author: lijunlong <lijunlong@openresty.com>
Date: Sun Apr 11 14:34:47 2021 +0800
feature: added a process exit callback point.
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index d7479fa4..c421e43c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -255,6 +255,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
+ ngx_proc_exit_top_handler = ngx_proc_exit_def_handler;
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 15680237..9d2e81c5 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -34,6 +34,7 @@ ngx_int_t ngx_process_slot;
ngx_socket_t ngx_channel;
ngx_int_t ngx_last_process;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+ngx_proc_exit_pt ngx_proc_exit_top_handler;
ngx_signal_t signals[] = {
@@ -83,6 +84,13 @@ ngx_signal_t signals[] = {
};
+void
+ngx_proc_exit_def_handler(ngx_pid_t pid)
+{
+ /* do nothing */
+}
+
+
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -557,6 +565,7 @@ ngx_process_get_status(void)
}
ngx_unlock_mutexes(pid);
+ ngx_proc_exit_top_handler(pid);
}
}
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 3986639b..c5972541 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -18,6 +18,7 @@ typedef pid_t ngx_pid_t;
#define NGX_INVALID_PID -1
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
+typedef void (*ngx_proc_exit_pt)(ngx_pid_t pid);
typedef struct {
ngx_pid_t pid;
@@ -66,6 +67,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
ngx_int_t ngx_init_signals(ngx_log_t *log);
void ngx_debug_point(void);
+void ngx_proc_exit_def_handler(ngx_pid_t pid);
#if (NGX_HAVE_SCHED_YIELD)
@@ -85,6 +87,7 @@ extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+extern ngx_proc_exit_pt ngx_proc_exit_top_handler;
#endif /* _NGX_PROCESS_H_INCLUDED_ */

@ -0,0 +1,80 @@
commit 29cafd35fb2b7cff759fb4c9b84fa4600875321f
Author: lijunlong <lijunlong@openresty.com>
Date: Sun Apr 11 14:34:47 2021 +0800
feature: added a process exit callback point.
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index d7479fa4..c421e43c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -255,6 +255,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
+ ngx_proc_exit_top_handler = ngx_proc_exit_def_handler;
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 15680237..9d2e81c5 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -34,6 +34,7 @@ ngx_int_t ngx_process_slot;
ngx_socket_t ngx_channel;
ngx_int_t ngx_last_process;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+ngx_proc_exit_pt ngx_proc_exit_top_handler;
ngx_signal_t signals[] = {
@@ -83,6 +84,13 @@ ngx_signal_t signals[] = {
};
+void
+ngx_proc_exit_def_handler(ngx_pid_t pid)
+{
+ /* do nothing */
+}
+
+
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -557,6 +565,7 @@ ngx_process_get_status(void)
}
ngx_unlock_mutexes(pid);
+ ngx_proc_exit_top_handler(pid);
}
}
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 3986639b..c5972541 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -18,6 +18,7 @@ typedef pid_t ngx_pid_t;
#define NGX_INVALID_PID -1
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
+typedef void (*ngx_proc_exit_pt)(ngx_pid_t pid);
typedef struct {
ngx_pid_t pid;
@@ -66,6 +67,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
ngx_int_t ngx_init_signals(ngx_log_t *log);
void ngx_debug_point(void);
+void ngx_proc_exit_def_handler(ngx_pid_t pid);
#if (NGX_HAVE_SCHED_YIELD)
@@ -85,6 +87,7 @@ extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+extern ngx_proc_exit_pt ngx_proc_exit_top_handler;
#endif /* _NGX_PROCESS_H_INCLUDED_ */

@ -0,0 +1,80 @@
commit 29cafd35fb2b7cff759fb4c9b84fa4600875321f
Author: lijunlong <lijunlong@openresty.com>
Date: Sun Apr 11 14:34:47 2021 +0800
feature: added a process exit callback point.
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index d7479fa4..c421e43c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -255,6 +255,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
+ ngx_proc_exit_top_handler = ngx_proc_exit_def_handler;
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 15680237..9d2e81c5 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -34,6 +34,7 @@ ngx_int_t ngx_process_slot;
ngx_socket_t ngx_channel;
ngx_int_t ngx_last_process;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+ngx_proc_exit_pt ngx_proc_exit_top_handler;
ngx_signal_t signals[] = {
@@ -83,6 +84,13 @@ ngx_signal_t signals[] = {
};
+void
+ngx_proc_exit_def_handler(ngx_pid_t pid)
+{
+ /* do nothing */
+}
+
+
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -557,6 +565,7 @@ ngx_process_get_status(void)
}
ngx_unlock_mutexes(pid);
+ ngx_proc_exit_top_handler(pid);
}
}
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 3986639b..c5972541 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -18,6 +18,7 @@ typedef pid_t ngx_pid_t;
#define NGX_INVALID_PID -1
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
+typedef void (*ngx_proc_exit_pt)(ngx_pid_t pid);
typedef struct {
ngx_pid_t pid;
@@ -66,6 +67,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
ngx_int_t ngx_init_signals(ngx_log_t *log);
void ngx_debug_point(void);
+void ngx_proc_exit_def_handler(ngx_pid_t pid);
#if (NGX_HAVE_SCHED_YIELD)
@@ -85,6 +87,7 @@ extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+extern ngx_proc_exit_pt ngx_proc_exit_top_handler;
#endif /* _NGX_PROCESS_H_INCLUDED_ */

@ -0,0 +1,80 @@
commit 29cafd35fb2b7cff759fb4c9b84fa4600875321f
Author: lijunlong <lijunlong@openresty.com>
Date: Sun Apr 11 14:34:47 2021 +0800
feature: added a process exit callback point.
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index d7479fa4..c421e43c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -255,6 +255,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
+ ngx_proc_exit_top_handler = ngx_proc_exit_def_handler;
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 15680237..9d2e81c5 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -34,6 +34,7 @@ ngx_int_t ngx_process_slot;
ngx_socket_t ngx_channel;
ngx_int_t ngx_last_process;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+ngx_proc_exit_pt ngx_proc_exit_top_handler;
ngx_signal_t signals[] = {
@@ -83,6 +84,13 @@ ngx_signal_t signals[] = {
};
+void
+ngx_proc_exit_def_handler(ngx_pid_t pid)
+{
+ /* do nothing */
+}
+
+
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -557,6 +565,7 @@ ngx_process_get_status(void)
}
ngx_unlock_mutexes(pid);
+ ngx_proc_exit_top_handler(pid);
}
}
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 3986639b..c5972541 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -18,6 +18,7 @@ typedef pid_t ngx_pid_t;
#define NGX_INVALID_PID -1
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
+typedef void (*ngx_proc_exit_pt)(ngx_pid_t pid);
typedef struct {
ngx_pid_t pid;
@@ -66,6 +67,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
ngx_int_t ngx_init_signals(ngx_log_t *log);
void ngx_debug_point(void);
+void ngx_proc_exit_def_handler(ngx_pid_t pid);
#if (NGX_HAVE_SCHED_YIELD)
@@ -85,6 +87,7 @@ extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+extern ngx_proc_exit_pt ngx_proc_exit_top_handler;
#endif /* _NGX_PROCESS_H_INCLUDED_ */

@ -0,0 +1,80 @@
commit 29cafd35fb2b7cff759fb4c9b84fa4600875321f
Author: lijunlong <lijunlong@openresty.com>
Date: Sun Apr 11 14:34:47 2021 +0800
feature: added a process exit callback point.
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index d7479fa4..c421e43c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -255,6 +255,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
+ ngx_proc_exit_top_handler = ngx_proc_exit_def_handler;
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 15680237..9d2e81c5 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -34,6 +34,7 @@ ngx_int_t ngx_process_slot;
ngx_socket_t ngx_channel;
ngx_int_t ngx_last_process;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+ngx_proc_exit_pt ngx_proc_exit_top_handler;
ngx_signal_t signals[] = {
@@ -83,6 +84,13 @@ ngx_signal_t signals[] = {
};
+void
+ngx_proc_exit_def_handler(ngx_pid_t pid)
+{
+ /* do nothing */
+}
+
+
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -557,6 +565,7 @@ ngx_process_get_status(void)
}
ngx_unlock_mutexes(pid);
+ ngx_proc_exit_top_handler(pid);
}
}
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 3986639b..c5972541 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -18,6 +18,7 @@ typedef pid_t ngx_pid_t;
#define NGX_INVALID_PID -1
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
+typedef void (*ngx_proc_exit_pt)(ngx_pid_t pid);
typedef struct {
ngx_pid_t pid;
@@ -66,6 +67,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
ngx_int_t ngx_init_signals(ngx_log_t *log);
void ngx_debug_point(void);
+void ngx_proc_exit_def_handler(ngx_pid_t pid);
#if (NGX_HAVE_SCHED_YIELD)
@@ -85,6 +87,7 @@ extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+extern ngx_proc_exit_pt ngx_proc_exit_top_handler;
#endif /* _NGX_PROCESS_H_INCLUDED_ */

@ -0,0 +1,80 @@
commit 29cafd35fb2b7cff759fb4c9b84fa4600875321f
Author: lijunlong <lijunlong@openresty.com>
Date: Sun Apr 11 14:34:47 2021 +0800
feature: added a process exit callback point.
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index d7479fa4..c421e43c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -255,6 +255,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
+ ngx_proc_exit_top_handler = ngx_proc_exit_def_handler;
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 15680237..9d2e81c5 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -34,6 +34,7 @@ ngx_int_t ngx_process_slot;
ngx_socket_t ngx_channel;
ngx_int_t ngx_last_process;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+ngx_proc_exit_pt ngx_proc_exit_top_handler;
ngx_signal_t signals[] = {
@@ -83,6 +84,13 @@ ngx_signal_t signals[] = {
};
+void
+ngx_proc_exit_def_handler(ngx_pid_t pid)
+{
+ /* do nothing */
+}
+
+
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -557,6 +565,7 @@ ngx_process_get_status(void)
}
ngx_unlock_mutexes(pid);
+ ngx_proc_exit_top_handler(pid);
}
}
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 3986639b..c5972541 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -18,6 +18,7 @@ typedef pid_t ngx_pid_t;
#define NGX_INVALID_PID -1
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
+typedef void (*ngx_proc_exit_pt)(ngx_pid_t pid);
typedef struct {
ngx_pid_t pid;
@@ -66,6 +67,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
ngx_int_t ngx_init_signals(ngx_log_t *log);
void ngx_debug_point(void);
+void ngx_proc_exit_def_handler(ngx_pid_t pid);
#if (NGX_HAVE_SCHED_YIELD)
@@ -85,6 +87,7 @@ extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+extern ngx_proc_exit_pt ngx_proc_exit_top_handler;
#endif /* _NGX_PROCESS_H_INCLUDED_ */

@ -0,0 +1,80 @@
commit 29cafd35fb2b7cff759fb4c9b84fa4600875321f
Author: lijunlong <lijunlong@openresty.com>
Date: Sun Apr 11 14:34:47 2021 +0800
feature: added a process exit callback point.
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index d7479fa4..c421e43c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -255,6 +255,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}
+ ngx_proc_exit_top_handler = ngx_proc_exit_def_handler;
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 15680237..9d2e81c5 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -34,6 +34,7 @@ ngx_int_t ngx_process_slot;
ngx_socket_t ngx_channel;
ngx_int_t ngx_last_process;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+ngx_proc_exit_pt ngx_proc_exit_top_handler;
ngx_signal_t signals[] = {
@@ -83,6 +84,13 @@ ngx_signal_t signals[] = {
};
+void
+ngx_proc_exit_def_handler(ngx_pid_t pid)
+{
+ /* do nothing */
+}
+
+
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
char *name, ngx_int_t respawn)
@@ -557,6 +565,7 @@ ngx_process_get_status(void)
}
ngx_unlock_mutexes(pid);
+ ngx_proc_exit_top_handler(pid);
}
}
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 3986639b..c5972541 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -18,6 +18,7 @@ typedef pid_t ngx_pid_t;
#define NGX_INVALID_PID -1
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
+typedef void (*ngx_proc_exit_pt)(ngx_pid_t pid);
typedef struct {
ngx_pid_t pid;
@@ -66,6 +67,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
ngx_int_t ngx_init_signals(ngx_log_t *log);
void ngx_debug_point(void);
+void ngx_proc_exit_def_handler(ngx_pid_t pid);
#if (NGX_HAVE_SCHED_YIELD)
@@ -85,6 +87,7 @@ extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
+extern ngx_proc_exit_pt ngx_proc_exit_top_handler;
#endif /* _NGX_PROCESS_H_INCLUDED_ */

@ -541,6 +541,13 @@ echo "$info_txt applying the reuseport_close_unused_fds patch for nginx"
patch -p1 < $root/patches/nginx-$main_ver-reuseport_close_unused_fds.patch || exit 1
echo
answer=`$root/util/ver-ge "$main_ver" 1.19.9`
if [ "$answer" = "Y" ]; then
echo "$info_txt applying nginx-$main_ver-proc_exit_handler patch for nginx"
patch -p1 < $root/patches/nginx-$main_ver-proc_exit_handler.patch || exit 1
fi
cp $root/html/index.html docs/html/ || exit 1
cp $root/html/50x.html docs/html/ || exit 1

Loading…
Cancel
Save