Changeset 8680


Ignore:
Timestamp:
Jun 12, 2009, 10:17:59 PM (13 years ago)
Author:
charles
Message:

(trunk libT) make sure tr_sessionSetDHTEnabled() doesn't make libevent calls outside of the libevent thread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/session.c

    r8660 r8680  
    15991599}
    16001600
     1601static void
     1602toggleDHTImpl(  void * data )
     1603{
     1604    tr_session * session = data;
     1605    assert( tr_isSession( session ) );
     1606
     1607    if( session->isDHTEnabled )
     1608        tr_dhtUninit( session );
     1609
     1610    session->isDHTEnabled = !session->isDHTEnabled;
     1611
     1612    if( session->isDHTEnabled )
     1613        tr_dhtInit( session );
     1614}
     1615
    16011616void
    16021617tr_sessionSetDHTEnabled( tr_session * session, tr_bool enabled )
    16031618{
    16041619    assert( tr_isSession( session ) );
    1605 
    1606     if( ( enabled!=0 ) != (session->isDHTEnabled!=0) )
    1607     {
    1608         if( session->isDHTEnabled )
    1609             tr_dhtUninit( session );
    1610 
    1611         session->isDHTEnabled = enabled!=0;
    1612 
    1613         if( session->isDHTEnabled )
    1614             tr_dhtInit( session );
    1615     }
     1620    assert( tr_isBool( enabled ) );
     1621
     1622    if( ( enabled != 0 ) != ( session->isDHTEnabled != 0 ) )
     1623        tr_runInEventThread( session, toggleDHTImpl, session );
    16161624}
    16171625
Note: See TracChangeset for help on using the changeset viewer.