From 34e8174ee8a82e0ec115f745e19b13c10686b109 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 17 Aug 2007 03:37:45 +0000 Subject: [PATCH] shut down the libevent thread gracefully on shutdown --- libtransmission/transmission.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index 8ae80c6c5..ef3eb2501 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -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 **