Changeset 6819


Ignore:
Timestamp:
Oct 1, 2008, 4:26:38 AM (13 years ago)
Author:
charles
Message:

(libT) maybe fix the evhttp issues that softwareelves reported

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r6817 r6819  
    399399
    400400static void
    401 startServer( tr_rpc_server * server )
    402 {
     401startServer( void * vserver )
     402{
     403    tr_rpc_server * server  = vserver;
     404
    403405    fprintf( stderr, "%s:%d in startServer; current context is %p\n", __FILE__, __LINE__, server->httpd );
    404406
     
    424426}
    425427
    426 void
    427 tr_rpcSetEnabled( tr_rpc_server * server,
    428                   int             isEnabled )
    429 {
    430     server->isEnabled = isEnabled != 0;
    431 
    432     if( !isEnabled )
     428static void
     429onEnabledChanged( void * vserver )
     430{
     431    tr_rpc_server * server = vserver;
     432
     433    if( !server->isEnabled )
    433434        stopServer( server );
    434435    else
    435436        startServer( server );
    436437}
     438   
     439
     440void
     441tr_rpcSetEnabled( tr_rpc_server * server,
     442                  int             isEnabled )
     443{
     444    server->isEnabled = isEnabled != 0;
     445
     446    tr_runInEventThread( server->session, onEnabledChanged, server );
     447}
    437448
    438449int
     
    442453}
    443454
     455static void
     456restartServer( void * vserver )
     457{
     458    tr_rpc_server * server = vserver;
     459
     460    if( server->isEnabled )
     461    {
     462        stopServer( server );
     463        startServer( server );
     464    }
     465}
     466
    444467void
    445468tr_rpcSetPort( tr_rpc_server * server,
     
    451474
    452475        if( server->isEnabled )
    453         {
    454             stopServer( server );
    455             startServer( server );
    456         }
     476            tr_runInEventThread( server->session, restartServer, server );
    457477    }
    458478}
     
    530550****/
    531551
    532 void
    533 tr_rpcClose( tr_rpc_server ** ps )
    534 {
    535     tr_rpc_server * s = *ps;
    536 
    537     *ps = NULL;
    538 
     552static void
     553closeServer( void * vserver )
     554{
     555    tr_rpc_server * s = vserver;
    539556    stopServer( s );
    540557    tr_free( s->acl );
     
    542559    tr_free( s->password );
    543560    tr_free( s );
     561}
     562
     563void
     564tr_rpcClose( tr_rpc_server ** ps )
     565{
     566    tr_runInEventThread( (*ps)->session, closeServer, *ps );
     567    *ps = NULL;
    544568}
    545569
     
    563587    s->isPasswordEnabled = isPasswordEnabled != 0;
    564588    s->isEnabled = isEnabled != 0;
    565 
    566589    if( isEnabled )
    567         startServer( s );
     590        tr_runInEventThread( session, startServer, s );
    568591    return s;
    569592}
  • trunk/libtransmission/trevent.c

    r6811 r6819  
    146146libeventThreadFunc( void * veh )
    147147{
    148     tr_event_handle * eh = (tr_event_handle *) veh;
     148    tr_event_handle * eh = veh;
    149149
    150150    tr_dbg( "Starting libevent thread" );
     
    155155#endif
    156156
    157     eh->base = event_init( );
    158157    eh->h->events = eh;
    159     event_set_log_callback( logFunc );
    160158
    161159    /* listen to the pipe's read fd */
     
    183181    pipe( eh->fds );
    184182    eh->h = handle;
     183    eh->base = event_init( );
    185184    eh->thread = tr_threadNew( libeventThreadFunc, eh );
    186185}
Note: See TracChangeset for help on using the changeset viewer.