Do a more graceful termination of the client if main server closes the CMD fd.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-06-01 13:00:33 +02:00
parent 48c2477d1f
commit 3db871bb43
3 changed files with 7 additions and 1 deletions

View File

@@ -82,6 +82,7 @@ extern int syslog_open;
#define ERR_EXEC -10
#define ERR_PEER_TERMINATED -11
#define ERR_CTL -12
#define ERR_NO_CMD_FD -13
#define ERR_WORKER_TERMINATED ERR_PEER_TERMINATED

View File

@@ -93,7 +93,7 @@ int handle_worker_commands(struct worker_st *ws)
if (ret == 0) {
oclog(ws, LOG_ERR, "parent terminated");
exit(0);
return ERR_NO_CMD_FD;
}
if (length > ret - 3) {

View File

@@ -1860,6 +1860,7 @@ static int connect_handler(worker_st * ws)
}
if (terminate != 0) {
terminate:
ws->buffer[0] = 'S';
ws->buffer[1] = 'T';
ws->buffer[2] = 'F';
@@ -1936,6 +1937,10 @@ static int connect_handler(worker_st * ws)
/* read commands from command fd */
if (FD_ISSET(ws->cmd_fd, &rfds)) {
ret = handle_worker_commands(ws);
if (ret == ERR_NO_CMD_FD) {
goto terminate;
}
if (ret < 0) {
goto exit;
}