Changeset 3710


Ignore:
Timestamp:
Nov 5, 2007, 5:42:25 AM (15 years ago)
Author:
charles
Message:

ensure that tr_close() exits gracefully even when the trackers aren't responding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/transmission.c

    r3587 r3710  
    309309    h->isClosed = TRUE;
    310310}
     311
     312static int
     313deadlineReached( const uint64_t deadline )
     314{
     315    return tr_date( ) >= deadline;
     316}
     317
    311318void
    312319tr_close( tr_handle * h )
    313320{
     321    const int maxwait_msec = 6 * 1000;
     322    const uint64_t deadline = tr_date( ) + maxwait_msec;
     323
    314324    tr_runInEventThread( h, tr_closeImpl, h );
    315     while( !h->isClosed )
     325    while( !h->isClosed && !deadlineReached( deadline ) )
    316326        tr_wait( 100 );
    317327
    318328    tr_eventClose( h );
    319     while( h->events != NULL )
     329    while( h->events && !deadlineReached( deadline ) )
    320330        tr_wait( 100 );
    321331
Note: See TracChangeset for help on using the changeset viewer.