Removing logging from signal handler functions

This commit is contained in:
Alexandre Quesnel 2021-02-07 22:26:06 +00:00
parent 1b36f66e39
commit 2fba8d43ac
5 changed files with 25 additions and 20 deletions

View File

@ -142,15 +142,13 @@ g_xrdp_sync(long (*sync_func)(long param1, long param2), long sync_param1,
}
/*****************************************************************************/
/* Signal handler for SIGINT and SIGTERM
* Note: only signal safe code (eg. setting wait event) should be executed in
* this funciton. For more details see `man signal-safety`
*/
static void
xrdp_shutdown(int sig)
{
tbus threadid;
threadid = tc_get_threadid();
LOG(LOG_LEVEL_INFO, "shutting down");
LOG(LOG_LEVEL_INFO, "signal %d threadid %lld", sig, (long long)threadid);
if (!g_is_wait_obj_set(g_term_event))
{
g_set_wait_obj(g_term_event);
@ -158,6 +156,10 @@ xrdp_shutdown(int sig)
}
/*****************************************************************************/
/* Signal handler for SIGCHLD
* Note: only signal safe code (eg. setting wait event) should be executed in
* this funciton. For more details see `man signal-safety`
*/
static void
xrdp_child(int sig)
{
@ -169,10 +171,14 @@ xrdp_child(int sig)
}
/*****************************************************************************/
/* No-op signal handler.
* Note: only signal safe code (eg. setting wait event) should be executed in
* this funciton. For more details see `man signal-safety`
*/
static void
xrdp_hang_up(int sig)
xrdp_sig_no_op(int sig)
{
LOG(LOG_LEVEL_INFO, "caught SIGHUP, noop...");
/* no-op */
}
/*****************************************************************************/
@ -229,14 +235,6 @@ g_get_sync_event(void)
return g_sync_event;
}
/*****************************************************************************/
static void
pipe_sig(int sig_num)
{
/* do nothing */
LOG(LOG_LEVEL_INFO, "got XRDP SIGPIPE(%d)", sig_num);
}
/*****************************************************************************/
/*Some function must be called from the main thread.
if g_sync_command==THREAD_WAITING a function is waiting to be processed*/
@ -678,10 +676,10 @@ main(int argc, char **argv)
g_threadid = tc_get_threadid();
g_listen = xrdp_listen_create();
g_signal_user_interrupt(xrdp_shutdown); /* SIGINT */
g_signal_pipe(pipe_sig); /* SIGPIPE */
g_signal_pipe(xrdp_sig_no_op); /* SIGPIPE */
g_signal_terminate(xrdp_shutdown); /* SIGTERM */
g_signal_child_stop(xrdp_child); /* SIGCHLD */
g_signal_hang_up(xrdp_hang_up); /* SIGHUP */
g_signal_hang_up(xrdp_sig_no_op); /* SIGHUP */
g_sync_mutex = tc_mutex_create();
g_sync1_mutex = tc_mutex_create();
pid = g_getpid();

View File

@ -482,7 +482,8 @@ proc_enc_msg(void *arg)
if (g_is_wait_obj_set(term_obj)) /* global term */
{
LOG_DEVEL(LOG_LEVEL_DEBUG, "proc_enc_msg: global term");
LOG(LOG_LEVEL_DEBUG,
"Received termination signal, stopping the encoder thread");
break;
}

View File

@ -912,6 +912,9 @@ xrdp_listen_main_loop(struct xrdp_listen *self)
if (g_is_wait_obj_set(term_obj)) /* termination called */
{
LOG(LOG_LEVEL_INFO,
"Received termination signal, stopping the server accept new "
"connections thread");
break;
}

View File

@ -1221,7 +1221,7 @@ load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
LOG(LOG_LEVEL_DEBUG, "new_cursors: %d", globals->new_cursors);
LOG(LOG_LEVEL_DEBUG, "nego_sec_layer: %d", globals->nego_sec_layer);
LOG(LOG_LEVEL_DEBUG, "allow_multimon: %d", globals->allow_multimon);
LOG(LOG_LEVEL_DEBUG, "enable_token_login: %d", globals->enable_token_login)
LOG(LOG_LEVEL_DEBUG, "enable_token_login: %d", globals->enable_token_login);
LOG(LOG_LEVEL_DEBUG, "ls_top_window_bg_color: %x", globals->ls_top_window_bg_color);
LOG(LOG_LEVEL_DEBUG, "ls_width: %d", globals->ls_width);

View File

@ -273,6 +273,9 @@ xrdp_process_main_loop(struct xrdp_process *self)
if (g_is_wait_obj_set(term_obj)) /* term */
{
LOG(LOG_LEVEL_DEBUG,
"Received termination signal, stopping the client message "
"processor thread");
break;
}