worker: improved exit reason reporting for server disconnects

This commit is contained in:
Nikos Mavrogiannopoulos
2016-03-07 13:56:12 +01:00
parent da4e4fcf2a
commit eb71a82210
3 changed files with 5 additions and 6 deletions

View File

@@ -93,7 +93,7 @@ int handle_commands_from_main(struct worker_st *ws)
ret = recv_msg_data(ws->cmd_fd, &cmd, cmd_data, sizeof(cmd_data), &fd);
if (ret < 0) {
oclog(ws, LOG_DEBUG, "cannot obtain data from command socket");
exit_worker(ws);
exit_worker_reason(ws, REASON_SERVER_DISCONNECT);
}
if (ret == 0) {
@@ -109,7 +109,7 @@ int handle_commands_from_main(struct worker_st *ws)
switch(cmd) {
case CMD_TERMINATE:
exit_worker(ws);
exit_worker_reason(ws, REASON_SERVER_DISCONNECT);
case CMD_UDP_FD: {
unsigned has_hello = 1;
@@ -158,7 +158,7 @@ int handle_commands_from_main(struct worker_st *ws)
break;
default:
oclog(ws, LOG_ERR, "unknown CMD 0x%x", (unsigned)cmd);
exit_worker(ws);
exit_worker_reason(ws, REASON_ERROR);
}
return 0;

View File

@@ -83,8 +83,6 @@ static int parse_cstp_data(struct worker_st *ws, uint8_t * buf, size_t buf_size,
time_t);
static int parse_dtls_data(struct worker_st *ws, uint8_t * buf, size_t buf_size,
time_t);
void exit_worker(worker_st * ws);
static void exit_worker_reason(worker_st * ws, unsigned reason);
static int connect_handler(worker_st * ws);
static void session_info_send(worker_st * ws);
@@ -364,7 +362,7 @@ void exit_worker(worker_st * ws)
exit_worker_reason(ws, REASON_ANY);
}
static void exit_worker_reason(worker_st * ws, unsigned reason)
void exit_worker_reason(worker_st * ws, unsigned reason)
{
/* send statistics to parent */
if (ws->auth_state == S_AUTH_COMPLETE) {

View File

@@ -333,6 +333,7 @@ int disable_system_calls(struct worker_st *ws);
void ocsigaltstack(struct worker_st *ws);
void exit_worker(worker_st * ws);
void exit_worker_reason(worker_st * ws, unsigned reason);
int ws_switch_auth_to(struct worker_st *ws, unsigned auth);
void ws_disable_auth(struct worker_st *ws, unsigned auth);