Shut down ipc server on fatal signal, not just torrent client.
This commit is contained in:
parent
78f65331f2
commit
aafd6488af
|
@ -344,7 +344,7 @@ gotsig( int sig, short what UNUSED, void * arg UNUSED )
|
||||||
{
|
{
|
||||||
exiting = 1;
|
exiting = 1;
|
||||||
errmsg( "received fatal signal %i, attempting to exit cleanly", sig );
|
errmsg( "received fatal signal %i, attempting to exit cleanly", sig );
|
||||||
torrent_exit( 0 );
|
server_quit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,6 +185,21 @@ server_listen( int fd )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
server_quit( void )
|
||||||
|
{
|
||||||
|
struct client * ii, * next;
|
||||||
|
|
||||||
|
torrent_exit( 0 );
|
||||||
|
gl_exiting = 1;
|
||||||
|
|
||||||
|
for( ii = RB_MIN( allclients, &gl_clients ); NULL != ii; ii = next )
|
||||||
|
{
|
||||||
|
next = RB_NEXT( allclients, &gl_clients, ii );
|
||||||
|
byebye( ii->ev, EVBUFFER_EOF, NULL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
newclient( int fd, short event UNUSED, void * arg )
|
newclient( int fd, short event UNUSED, void * arg )
|
||||||
{
|
{
|
||||||
|
@ -560,16 +575,7 @@ void
|
||||||
quitmsg( enum ipc_msg id UNUSED, benc_val_t * val UNUSED, int64_t tag UNUSED,
|
quitmsg( enum ipc_msg id UNUSED, benc_val_t * val UNUSED, int64_t tag UNUSED,
|
||||||
void * arg UNUSED )
|
void * arg UNUSED )
|
||||||
{
|
{
|
||||||
struct client * ii, * next;
|
server_quit();
|
||||||
|
|
||||||
torrent_exit( 0 );
|
|
||||||
gl_exiting = 1;
|
|
||||||
|
|
||||||
for( ii = RB_MIN( allclients, &gl_clients ); NULL != ii; ii = next )
|
|
||||||
{
|
|
||||||
next = RB_NEXT( allclients, &gl_clients, ii );
|
|
||||||
byebye( ii->ev, EVBUFFER_EOF, NULL );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -30,5 +30,6 @@ struct event_base;
|
||||||
int server_init( struct event_base * );
|
int server_init( struct event_base * );
|
||||||
void server_debug( int );
|
void server_debug( int );
|
||||||
int server_listen( int );
|
int server_listen( int );
|
||||||
|
void server_quit( void );
|
||||||
|
|
||||||
#endif /* TR_DAEMON_SERVER_H */
|
#endif /* TR_DAEMON_SERVER_H */
|
||||||
|
|
Loading…
Reference in New Issue