Browse Source

Rework the handover mechanism to make the old client reject further clients, then send a reconnect, then shutdown and wait before killing it

master
Con Kolivas 10 years ago
parent
commit
86fa46069c
  1. 28
      src/ckpool.c

28
src/ckpool.c

@ -784,7 +784,7 @@ int process_exit(ckpool_t *ckp, proc_instance_t *pi, int ret)
LOGWARNING("%s %s exiting with return code %d, shutting down!",
ckp->name, pi->processname, ret);
send_proc(&ckp->main, "shutdown");
sleep(1);
cksleep_ms(100);
ret = 1;
} else /* Should be part of a normal shutdown */
LOGNOTICE("%s %s exited normally", ckp->name, pi->processname);
@ -856,8 +856,8 @@ static void sighandler(int sig)
cancel_join_pthread(&ckp->pth_watchdog);
__shutdown_children(ckp, SIGUSR1);
/* Wait a second, then send SIGKILL */
sleep(1);
/* Wait, then send SIGKILL */
cksleep_ms(100);
__shutdown_children(ckp, SIGKILL);
cancel_pthread(&ckp->pth_listener);
exit(0);
@ -1106,6 +1106,18 @@ static struct option long_options[] = {
};
#endif
static void send_recv_path(const char *path, const char *msg)
{
int sockd = open_unix_client(path);
char *response;
send_unix_msg(sockd, msg);
response = recv_unix_msg(sockd);
LOGWARNING("Received: %s in response to %s request", response, msg);
dealloc(response);
Close(sockd);
}
int main(int argc, char **argv)
{
struct sigaction handler;
@ -1324,13 +1336,15 @@ int main(int argc, char **argv)
if (sockd > 0 && send_unix_msg(sockd, "getfd")) {
ckp.oldconnfd = get_fd(sockd);
Close(sockd);
sockd = open_unix_client(ckp.main.us.path);
send_unix_msg(sockd, "shutdown");
send_recv_path(ckp.main.us.path, "reject");
send_recv_path(ckp.main.us.path, "reconnect");
send_recv_path(ckp.main.us.path, "shutdown");
cksleep_ms(500);
if (ckp.oldconnfd > 0)
LOGWARNING("Inherited old socket with new file descriptor %d!", ckp.oldconnfd);
Close(sockd);
}
}

Loading…
Cancel
Save