shut down the libevent thread gracefully on shutdown

This commit is contained in:
Charles Kerr 2007-08-17 03:37:45 +00:00
parent 0c60e29934
commit 34e8174ee8
1 changed files with 6 additions and 1 deletions

View File

@ -63,12 +63,14 @@ tr_peerIdNew ( char * buf, int buflen )
buf[TR_ID_LEN] = '\0';
}
static int shuttingDown = FALSE;
static void
libeventThreadFunc( void * unused UNUSED )
{
tr_dbg( "libevent thread starting" );
event_init( );
for ( ;; )
while( !shuttingDown )
{
event_dispatch( );
tr_wait( 50 ); /* 1/20th of a second */
@ -246,6 +248,9 @@ void tr_close( tr_handle_t * h )
free( h );
tr_netResolveThreadClose();
/* end the event thread */
shuttingDown = TRUE;
}
tr_torrent_t **