mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 02:47:56 +08:00
linked master_service's all processes.
This commit is contained in:
parent
15e6ea1fa6
commit
a731cf5507
@ -50,6 +50,7 @@ typedef struct ACL_MASTER_SERV {
|
||||
#if 0
|
||||
struct ACL_BINHASH *children; /* linkage */
|
||||
#endif
|
||||
ACL_RING children; /* linkage children */
|
||||
struct ACL_MASTER_SERV *next; /* linkage */
|
||||
} ACL_MASTER_SERV;
|
||||
|
||||
@ -92,11 +93,12 @@ typedef struct ACL_MASTER_SERV {
|
||||
typedef int ACL_MASTER_PID; /* pid is key into binhash table */
|
||||
|
||||
typedef struct ACL_MASTER_PROC {
|
||||
ACL_MASTER_PID pid; /* child process id */
|
||||
unsigned gen; /* child generation number */
|
||||
int avail; /* availability */
|
||||
ACL_MASTER_SERV *serv; /* parent linkage */
|
||||
int use_count; /* number of service requests */
|
||||
ACL_RING me; /* linked in serv's children */
|
||||
unsigned gen; /* child generation number */
|
||||
int avail; /* availability */
|
||||
int use_count; /* number of service requests */
|
||||
ACL_MASTER_PID pid; /* child process id */
|
||||
ACL_MASTER_SERV *serv; /* parent linkage */
|
||||
} ACL_MASTER_PROC;
|
||||
|
||||
/*
|
||||
|
@ -694,6 +694,9 @@ ACL_MASTER_SERV *acl_master_ent_load(const char *filepath)
|
||||
service_args(xcp, serv, filepath);
|
||||
service_env(xcp, serv);
|
||||
|
||||
/* linked for children */
|
||||
acl_ring_init(&serv->children);
|
||||
|
||||
/* Backoff time in case a service is broken. */
|
||||
serv->throttle_delay = acl_var_master_throttle_time;
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h> /* closelog() */
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
@ -112,8 +111,8 @@ void acl_master_spawn(ACL_MASTER_SERV *serv)
|
||||
__FILE__, __LINE__, myname, serv->total_proc);
|
||||
|
||||
if (serv->avail_proc > 0 && (serv->prefork_proc <= 0
|
||||
|| serv->avail_proc > serv->prefork_proc))
|
||||
{
|
||||
|| serv->avail_proc > serv->prefork_proc)) {
|
||||
|
||||
acl_msg_warn("%s(%d)->%s: processes available: %d, "
|
||||
"processes prefork: %d", __FILE__, __LINE__,
|
||||
myname, serv->avail_proc, serv->prefork_proc);
|
||||
@ -250,6 +249,7 @@ void acl_master_spawn(ACL_MASTER_SERV *serv)
|
||||
proc->avail = 0;
|
||||
acl_binhash_enter(acl_var_master_child_table, (char *) &pid,
|
||||
sizeof(pid), (char *) proc);
|
||||
acl_ring_prepend(&serv->children, &proc->me);
|
||||
serv->total_proc++;
|
||||
acl_master_avail_more(serv, proc);
|
||||
if (serv->flags & ACL_MASTER_FLAG_CONDWAKE) {
|
||||
@ -297,6 +297,7 @@ static void master_delete_child(ACL_MASTER_PROC *proc)
|
||||
|
||||
acl_binhash_delete(acl_var_master_child_table, (void *) &proc->pid,
|
||||
sizeof(proc->pid), (void (*) (void *)) 0);
|
||||
acl_ring_detach(&proc->me);
|
||||
acl_myfree(proc);
|
||||
}
|
||||
|
||||
@ -321,19 +322,21 @@ void acl_master_reap_child(void)
|
||||
while ((pid = waitpid((pid_t) - 1, &status, WNOHANG)) > 0) {
|
||||
if (acl_msg_verbose)
|
||||
acl_msg_info("master_reap_child: pid %d", pid);
|
||||
|
||||
if ((proc = (ACL_MASTER_PROC *)
|
||||
acl_binhash_find(acl_var_master_child_table,
|
||||
(char *) &pid, sizeof(pid))) == 0) {
|
||||
acl_msg_warn("master_reap: unknown pid: %d", pid);
|
||||
continue;
|
||||
}
|
||||
serv = proc->serv;
|
||||
|
||||
if (ACL_NORMAL_EXIT_STATUS(status)) {
|
||||
master_delete_child(proc);
|
||||
continue;
|
||||
}
|
||||
|
||||
serv = proc->serv;
|
||||
|
||||
if (WIFEXITED(status)) {
|
||||
acl_msg_warn("%s(%d), %s: process %s pid %d "
|
||||
"exit status %d", __FILE__, __LINE__,
|
||||
@ -348,6 +351,7 @@ void acl_master_reap_child(void)
|
||||
serv->path, pid, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (WIFSIGNALED(status)) {
|
||||
acl_msg_warn("%s(%d), %s: process %s pid %d killed"
|
||||
" by signal %d", __FILE__, __LINE__, myname,
|
||||
@ -362,8 +366,10 @@ void acl_master_reap_child(void)
|
||||
serv->path, pid, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (proc->use_count == 0
|
||||
&& (serv->flags & ACL_MASTER_FLAG_THROTTLE) == 0) {
|
||||
|
||||
acl_msg_warn("%s(%d), %s: bad command startup, path=%s"
|
||||
" -- throttling", __FILE__, __LINE__,
|
||||
myname, serv->path);
|
||||
|
@ -115,7 +115,7 @@ OBJ_PATH = .
|
||||
SRC = $(wildcard *.cpp)
|
||||
OBJ = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(notdir $(SRC)))
|
||||
|
||||
$(shell mkdir ../../../dist/master/libexec/$(RPATH)/)
|
||||
$(shell -p mkdir ../../../dist/master/libexec/$(RPATH)/)
|
||||
|
||||
$(OBJ_PATH)/%.o: %.cpp
|
||||
$(COMPILE) $< -o $@
|
||||
|
Loading…
Reference in New Issue
Block a user