mirror of
https://github.com/transmission/transmission
synced 2025-03-05 19:18:19 +00:00
Wait for thread to exit before exiting program.
This commit is contained in:
parent
4a6abe06e7
commit
b0cc4f3ff0
1 changed files with 16 additions and 2 deletions
|
@ -108,11 +108,13 @@ char * getStringRatio( float ratio )
|
|||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
int i, error;
|
||||
int i, error, closed;
|
||||
tr_handle_t * h;
|
||||
const tr_stat_t * s;
|
||||
tr_handle_status_t * hstat;
|
||||
|
||||
closed = 0;
|
||||
|
||||
printf( "Transmission %s - http://transmission.m0k.org/\n\n",
|
||||
LONG_VERSION_STRING );
|
||||
|
||||
|
@ -323,6 +325,9 @@ int main( int argc, char ** argv )
|
|||
}
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
tr_torrentClose( tor );
|
||||
closed = 1;
|
||||
|
||||
/* Try for 5 seconds to delete any port mappings for nat traversal */
|
||||
tr_natTraversalEnable( h, 0 );
|
||||
for( i = 0; i < 10; i++ )
|
||||
|
@ -337,7 +342,16 @@ int main( int argc, char ** argv )
|
|||
}
|
||||
|
||||
cleanup:
|
||||
/* Close the torrent and wait for 5 seconds for the thread to exit */
|
||||
if( !closed )
|
||||
{
|
||||
tr_torrentClose( tor );
|
||||
}
|
||||
for( i = 0; 10 > i && 0 < tr_torrentCount( h ); i++ )
|
||||
{
|
||||
wait_msecs( 500 );
|
||||
}
|
||||
|
||||
tr_close( h );
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
Loading…
Add table
Reference in a new issue