Ignore:
Timestamp:
Aug 7, 2010, 3:29:50 AM (12 years ago)
Author:
charles
Message:

(trunk 2.0x) #3493 "transmission doesn't exit cleanly if LPD is disabled during the session" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0x/libtransmission/session.c

    r11005 r11149  
    629629
    630630    if( session->isDHTEnabled )
    631     {
    632631        tr_dhtInit( session, &session->public_ipv4->addr );
    633     }
    634 
    635     if( !session->isLPDEnabled )
    636         tr_ndbg( "LPD", _( "Local Peer Discovery disabled" ) );
    637     else if( tr_lpdInit( session, &session->public_ipv4->addr ) )
    638         tr_ninf( "LPD", _( "Local Peer Discovery active" ) );
     632
     633    if( session->isLPDEnabled )
     634        tr_lpdInit( session, &session->public_ipv4->addr );
    639635
    640636    /* cleanup */
     
    16291625    assert( tr_isSession( session ) );
    16301626
    1631     dbgmsg( "shutting down transmission session %p", session );
     1627    dbgmsg( "shutting down transmission session %p... now is %zu, deadline is %zu", session, (size_t)time(NULL), (size_t)deadline );
    16321628
    16331629    /* close the session */
     
    16461642           && !deadlineReached( deadline ) )
    16471643    {
    1648         dbgmsg( "waiting on port unmap (%p) or announcer (%p)",
    1649                 session->shared, session->announcer );
     1644        dbgmsg( "waiting on port unmap (%p) or announcer (%p)... now %zu deadline %zu",
     1645                session->shared, session->announcer, (size_t)time(NULL), (size_t)deadline );
    16501646        tr_wait_msec( 100 );
    16511647    }
     
    16581654    {
    16591655        static tr_bool forced = FALSE;
    1660         dbgmsg( "waiting for libtransmission thread to finish" );
     1656        dbgmsg( "waiting for libtransmission thread to finish... now %zu deadline %zu", (size_t)time(NULL), (size_t)deadline );
    16611657        tr_wait_msec( 500 );
    16621658        if( deadlineReached( deadline ) && !forced )
    16631659        {
     1660            dbgmsg( "calling event_loopbreak()" );
     1661            forced = TRUE;
    16641662            event_loopbreak( );
    1665             forced = TRUE;
    1666 
    1667             if( time( NULL ) >= deadline + 3 )
    1668                 break;
     1663        }
     1664        if( deadlineReached( deadline+3 ) )
     1665        {
     1666            dbgmsg( "deadline+3 reached... calling break...\n" );
     1667            break;
    16691668        }
    16701669    }
     
    18081807}
    18091808
    1810 void
    1811 tr_sessionSetLPDEnabled( tr_session * session,
    1812                          tr_bool      enabled )
    1813 {
    1814     assert( tr_isSession( session ) );
    1815 
    1816     session->isLPDEnabled = ( enabled != 0 );
     1809static void
     1810toggleLPDImpl(  void * data )
     1811{
     1812    tr_session * session = data;
     1813    assert( tr_isSession( session ) );
     1814
     1815    if( session->isLPDEnabled )
     1816        tr_lpdUninit( session );
     1817
     1818    session->isLPDEnabled = !session->isLPDEnabled;
     1819
     1820    if( session->isLPDEnabled )
     1821        tr_lpdInit( session, &session->public_ipv4->addr );
     1822}
     1823
     1824void
     1825tr_sessionSetLPDEnabled( tr_session * session, tr_bool enabled )
     1826{
     1827    assert( tr_isSession( session ) );
     1828    assert( tr_isBool( enabled ) );
     1829
     1830    if( ( enabled != 0 ) != ( session->isLPDEnabled != 0 ) )
     1831        tr_runInEventThread( session, toggleLPDImpl, session );
    18171832}
    18181833
Note: See TracChangeset for help on using the changeset viewer.