Changeset 11148


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/session.c

    r11046 r11148  
    643643
    644644    if( session->isDHTEnabled )
    645     {
    646645        tr_dhtInit( session, &session->public_ipv4->addr );
    647     }
    648 
    649     if( !session->isLPDEnabled )
    650         tr_ndbg( "LPD", _( "Local Peer Discovery disabled" ) );
    651     else if( tr_lpdInit( session, &session->public_ipv4->addr ) )
    652         tr_ninf( "LPD", _( "Local Peer Discovery active" ) );
     646
     647    if( session->isLPDEnabled )
     648        tr_lpdInit( session, &session->public_ipv4->addr );
    653649
    654650    /* cleanup */
     
    17311727    assert( tr_isSession( session ) );
    17321728
    1733     dbgmsg( "shutting down transmission session %p", session );
     1729    dbgmsg( "shutting down transmission session %p... now is %zu, deadline is %zu", session, (size_t)time(NULL), (size_t)deadline );
    17341730
    17351731    /* close the session */
     
    17481744           && !deadlineReached( deadline ) )
    17491745    {
    1750         dbgmsg( "waiting on port unmap (%p) or announcer (%p)",
    1751                 session->shared, session->announcer );
     1746        dbgmsg( "waiting on port unmap (%p) or announcer (%p)... now %zu deadline %zu",
     1747                session->shared, session->announcer, (size_t)time(NULL), (size_t)deadline );
    17521748        tr_wait_msec( 100 );
    17531749    }
     
    17601756    {
    17611757        static tr_bool forced = FALSE;
    1762         dbgmsg( "waiting for libtransmission thread to finish" );
     1758        dbgmsg( "waiting for libtransmission thread to finish... now %zu deadline %zu", (size_t)time(NULL), (size_t)deadline );
    17631759        tr_wait_msec( 500 );
    17641760        if( deadlineReached( deadline ) && !forced )
    17651761        {
     1762            dbgmsg( "calling event_loopbreak()" );
     1763            forced = TRUE;
    17661764            event_loopbreak( );
    1767             forced = TRUE;
    1768 
    1769             if( time( NULL ) >= deadline + 3 )
    1770                 break;
     1765        }
     1766        if( deadlineReached( deadline+3 ) )
     1767        {
     1768            dbgmsg( "deadline+3 reached... calling break...\n" );
     1769            break;
    17711770        }
    17721771    }
     
    19101909}
    19111910
    1912 void
    1913 tr_sessionSetLPDEnabled( tr_session * session,
    1914                          tr_bool      enabled )
    1915 {
    1916     assert( tr_isSession( session ) );
    1917 
    1918     session->isLPDEnabled = ( enabled != 0 );
     1911static void
     1912toggleLPDImpl(  void * data )
     1913{
     1914    tr_session * session = data;
     1915    assert( tr_isSession( session ) );
     1916
     1917    if( session->isLPDEnabled )
     1918        tr_lpdUninit( session );
     1919
     1920    session->isLPDEnabled = !session->isLPDEnabled;
     1921
     1922    if( session->isLPDEnabled )
     1923        tr_lpdInit( session, &session->public_ipv4->addr );
     1924}
     1925
     1926void
     1927tr_sessionSetLPDEnabled( tr_session * session, tr_bool enabled )
     1928{
     1929    assert( tr_isSession( session ) );
     1930    assert( tr_isBool( enabled ) );
     1931
     1932    if( ( enabled != 0 ) != ( session->isLPDEnabled != 0 ) )
     1933        tr_runInEventThread( session, toggleLPDImpl, session );
    19191934}
    19201935
Note: See TracChangeset for help on using the changeset viewer.