nghttpx: Remove last_worker_pid from Config
The last_worker_pid is known by inspecting the last entry of worker_processes.
This commit is contained in:
parent
494775a25d
commit
b9b648e0ed
19
src/shrpx.cc
19
src/shrpx.cc
|
@ -262,6 +262,18 @@ void worker_process_kill(int signum) {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Returns the last PID of worker process. Returns -1 if there is no
|
||||||
|
// worker process at the moment.
|
||||||
|
int worker_process_last_pid() {
|
||||||
|
if (worker_processes.empty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return worker_processes.back()->worker_pid;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int chown_to_running_user(const char *path) {
|
int chown_to_running_user(const char *path) {
|
||||||
return chown(path, get_config()->uid, get_config()->gid);
|
return chown(path, get_config()->uid, get_config()->gid);
|
||||||
|
@ -528,7 +540,7 @@ void worker_process_child_cb(struct ev_loop *loop, ev_child *w, int revents) {
|
||||||
|
|
||||||
worker_process_remove(wp);
|
worker_process_remove(wp);
|
||||||
|
|
||||||
if (get_config()->last_worker_pid == pid) {
|
if (worker_process_last_pid() == pid) {
|
||||||
ev_break(loop);
|
ev_break(loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1195,8 +1207,6 @@ int event_loop() {
|
||||||
|
|
||||||
worker_process_add(make_unique<WorkerProcess>(loop, pid, ipc_fd));
|
worker_process_add(make_unique<WorkerProcess>(loop, pid, ipc_fd));
|
||||||
|
|
||||||
mod_config()->last_worker_pid = pid;
|
|
||||||
|
|
||||||
// Write PID file when we are ready to accept connection from peer.
|
// Write PID file when we are ready to accept connection from peer.
|
||||||
// This makes easier to write restart script for nghttpx. Because
|
// This makes easier to write restart script for nghttpx. Because
|
||||||
// when we know that PID file is recreated, it means we can send
|
// when we know that PID file is recreated, it means we can send
|
||||||
|
@ -1246,7 +1256,6 @@ void fill_default_config(Config *config) {
|
||||||
config->num_worker = 1;
|
config->num_worker = 1;
|
||||||
config->conf_path = "/etc/nghttpx/nghttpx.conf";
|
config->conf_path = "/etc/nghttpx/nghttpx.conf";
|
||||||
config->pid = getpid();
|
config->pid = getpid();
|
||||||
config->last_worker_pid = -1;
|
|
||||||
|
|
||||||
if (ev_supported_backends() & ~ev_recommended_backends() & EVBACKEND_KQUEUE) {
|
if (ev_supported_backends() & ~ev_recommended_backends() & EVBACKEND_KQUEUE) {
|
||||||
config->ev_loop_flags = ev_recommended_backends() | EVBACKEND_KQUEUE;
|
config->ev_loop_flags = ev_recommended_backends() | EVBACKEND_KQUEUE;
|
||||||
|
@ -2539,8 +2548,6 @@ void reload_config(WorkerProcess *wp) {
|
||||||
|
|
||||||
worker_process_add(make_unique<WorkerProcess>(loop, pid, ipc_fd));
|
worker_process_add(make_unique<WorkerProcess>(loop, pid, ipc_fd));
|
||||||
|
|
||||||
new_config->last_worker_pid = pid;
|
|
||||||
|
|
||||||
auto old_config = replace_config(new_config.release());
|
auto old_config = replace_config(new_config.release());
|
||||||
|
|
||||||
assert(cur_config == old_config);
|
assert(cur_config == old_config);
|
||||||
|
|
|
@ -727,9 +727,6 @@ struct Config {
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
gid_t gid;
|
gid_t gid;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
// With reloading feature, we may have multiple worker PIDs at the
|
|
||||||
// given moment. This field tracks the last worker PID.
|
|
||||||
pid_t last_worker_pid;
|
|
||||||
bool verbose;
|
bool verbose;
|
||||||
bool daemon;
|
bool daemon;
|
||||||
bool http2_proxy;
|
bool http2_proxy;
|
||||||
|
|
Loading…
Reference in New Issue