mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
block TERM and INT from all but the main thread. (Pretty much untested; doesn't fix hang-on-SIGINT.)
This commit is contained in:
parent
43bf3cd50f
commit
1ff4d67bc0
4 changed files with 20 additions and 0 deletions
|
@ -213,6 +213,8 @@ class HttpInstance {
|
|||
static void*
|
||||
http_thread_main( void* arg )
|
||||
{
|
||||
blockSignals();
|
||||
|
||||
HttpInstance* inst = (HttpInstance*)arg;
|
||||
HttpState* state = inst->m_state;
|
||||
int sock = inst->m_sock;
|
||||
|
|
|
@ -195,6 +195,8 @@ XWThreadPool::get_process_packet( int socket )
|
|||
/* static */ void*
|
||||
XWThreadPool::tpool_main( void* closure )
|
||||
{
|
||||
blockSignals();
|
||||
|
||||
XWThreadPool* me = (XWThreadPool*)closure;
|
||||
return me->real_tpool_main();
|
||||
}
|
||||
|
@ -377,6 +379,8 @@ XWThreadPool::real_listener()
|
|||
/* static */ void*
|
||||
XWThreadPool::listener_main( void* closure )
|
||||
{
|
||||
blockSignals();
|
||||
|
||||
XWThreadPool* me = (XWThreadPool*)closure;
|
||||
return me->real_listener();
|
||||
}
|
||||
|
|
|
@ -437,6 +437,17 @@ uptime( void )
|
|||
return time(NULL) - startTime;
|
||||
}
|
||||
|
||||
void
|
||||
blockSignals( void )
|
||||
{
|
||||
sigset_t set;
|
||||
sigemptyset( &set );
|
||||
sigaddset( &set, SIGINT );
|
||||
sigaddset( &set, SIGTERM);
|
||||
int s = pthread_sigmask( SIG_BLOCK, &set, NULL );
|
||||
assert( 0 == s );
|
||||
}
|
||||
|
||||
int
|
||||
GetNSpawns(void)
|
||||
{
|
||||
|
@ -669,6 +680,7 @@ read_packet( int sock, unsigned char* buf, int buflen )
|
|||
static void*
|
||||
handle_proxy_tproc( void* closure )
|
||||
{
|
||||
blockSignals();
|
||||
int sock = (int)closure;
|
||||
|
||||
unsigned char buf[MAX_PROXY_MSGLEN];
|
||||
|
|
|
@ -23,6 +23,8 @@ bool send_with_length_unsafe( int socket, unsigned char* buf, int bufLen );
|
|||
|
||||
time_t uptime(void);
|
||||
|
||||
void blockSignals( void ); /* call from all but main thread */
|
||||
|
||||
int GetNSpawns(void);
|
||||
|
||||
int make_socket( unsigned long addr, unsigned short port );
|
||||
|
|
Loading…
Add table
Reference in a new issue