mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
Do a more graceful termination of the client if main server closes the CMD fd.
This commit is contained in:
@@ -82,6 +82,7 @@ extern int syslog_open;
|
|||||||
#define ERR_EXEC -10
|
#define ERR_EXEC -10
|
||||||
#define ERR_PEER_TERMINATED -11
|
#define ERR_PEER_TERMINATED -11
|
||||||
#define ERR_CTL -12
|
#define ERR_CTL -12
|
||||||
|
#define ERR_NO_CMD_FD -13
|
||||||
|
|
||||||
#define ERR_WORKER_TERMINATED ERR_PEER_TERMINATED
|
#define ERR_WORKER_TERMINATED ERR_PEER_TERMINATED
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ int handle_worker_commands(struct worker_st *ws)
|
|||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
oclog(ws, LOG_ERR, "parent terminated");
|
oclog(ws, LOG_ERR, "parent terminated");
|
||||||
exit(0);
|
return ERR_NO_CMD_FD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > ret - 3) {
|
if (length > ret - 3) {
|
||||||
|
|||||||
@@ -1860,6 +1860,7 @@ static int connect_handler(worker_st * ws)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (terminate != 0) {
|
if (terminate != 0) {
|
||||||
|
terminate:
|
||||||
ws->buffer[0] = 'S';
|
ws->buffer[0] = 'S';
|
||||||
ws->buffer[1] = 'T';
|
ws->buffer[1] = 'T';
|
||||||
ws->buffer[2] = 'F';
|
ws->buffer[2] = 'F';
|
||||||
@@ -1936,6 +1937,10 @@ static int connect_handler(worker_st * ws)
|
|||||||
/* read commands from command fd */
|
/* read commands from command fd */
|
||||||
if (FD_ISSET(ws->cmd_fd, &rfds)) {
|
if (FD_ISSET(ws->cmd_fd, &rfds)) {
|
||||||
ret = handle_worker_commands(ws);
|
ret = handle_worker_commands(ws);
|
||||||
|
if (ret == ERR_NO_CMD_FD) {
|
||||||
|
goto terminate;
|
||||||
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user