|
|
@ -31,7 +31,7 @@
|
|
|
|
#include <signal.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
|
|
|
|
extern struct config_sesman g_cfg;
|
|
|
|
extern struct config_sesman* g_cfg; /* in sesman.c */
|
|
|
|
|
|
|
|
|
|
|
|
static pthread_t g_thread_sighandler;
|
|
|
|
static pthread_t g_thread_sighandler;
|
|
|
|
//static pthread_t g_thread_updater;
|
|
|
|
//static pthread_t g_thread_updater;
|
|
|
@ -62,14 +62,14 @@ thread_sighandler_start(void)
|
|
|
|
sigaddset(&waitmask, SIGFPE);
|
|
|
|
sigaddset(&waitmask, SIGFPE);
|
|
|
|
pthread_sigmask(SIG_UNBLOCK, &waitmask, NULL);
|
|
|
|
pthread_sigmask(SIG_UNBLOCK, &waitmask, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_INFO,"starting signal handling thread...");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_INFO,"starting signal handling thread...");
|
|
|
|
|
|
|
|
|
|
|
|
ret = pthread_create(&g_thread_sighandler, NULL, sig_handler_thread, "");
|
|
|
|
ret = pthread_create(&g_thread_sighandler, NULL, sig_handler_thread, "");
|
|
|
|
pthread_detach(g_thread_sighandler);
|
|
|
|
pthread_detach(g_thread_sighandler);
|
|
|
|
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_INFO, "signal handler thread started successfully");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_INFO, "signal handler thread started successfully");
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -77,16 +77,16 @@ thread_sighandler_start(void)
|
|
|
|
switch (ret)
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case EINVAL:
|
|
|
|
case EINVAL:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EAGAIN:
|
|
|
|
case EAGAIN:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EPERM:
|
|
|
|
case EPERM:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "unknown error starting signal handling thread");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting signal handling thread");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
@ -108,7 +108,7 @@ thread_session_update_start(void)
|
|
|
|
|
|
|
|
|
|
|
|
if (ret==0)
|
|
|
|
if (ret==0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_INFO, "session update thread started successfully");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_INFO, "session update thread started successfully");
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -116,16 +116,16 @@ thread_session_update_start(void)
|
|
|
|
switch (ret)
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case EINVAL:
|
|
|
|
case EINVAL:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EAGAIN:
|
|
|
|
case EAGAIN:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EPERM:
|
|
|
|
case EPERM:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "unknown error starting session update thread");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting session update thread");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
@ -150,7 +150,7 @@ thread_scp_start(int skt)
|
|
|
|
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt);
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -158,16 +158,16 @@ thread_scp_start(int skt)
|
|
|
|
switch (ret)
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case EINVAL:
|
|
|
|
case EINVAL:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt);
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EAGAIN:
|
|
|
|
case EAGAIN:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt);
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EPERM:
|
|
|
|
case EPERM:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt);
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
log_message(&(g_cfg.log), LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d");
|
|
|
|
log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|