Shut down ipc server on fatal signal, not just torrent client.

This commit is contained in:
Josh Elsasser 2007-08-17 03:57:26 +00:00
parent 78f65331f2
commit aafd6488af
3 changed files with 18 additions and 11 deletions

View File

@ -344,7 +344,7 @@ gotsig( int sig, short what UNUSED, void * arg UNUSED )
{
exiting = 1;
errmsg( "received fatal signal %i, attempting to exit cleanly", sig );
torrent_exit( 0 );
server_quit();
}
else
{

View File

@ -185,6 +185,21 @@ server_listen( int fd )
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
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,
void * arg UNUSED )
{
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 );
}
server_quit();
}
void

View File

@ -30,5 +30,6 @@ struct event_base;
int server_init( struct event_base * );
void server_debug( int );
int server_listen( int );
void server_quit( void );
#endif /* TR_DAEMON_SERVER_H */