Changeset 3267


Ignore:
Timestamp:
Oct 2, 2007, 2:59:07 AM (15 years ago)
Author:
charles
Message:

threads. gotta love 'em.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r3260 r3267  
    7676canReadWrapper( struct bufferevent * e, void * userData )
    7777{
     78    int done = 0;
    7879    tr_peerIo * c = (tr_peerIo *) userData;
     80    tr_handle * handle = c->handle;
    7981
    8082    if( c->canRead == NULL )
    8183        return;
    8284
    83     for( ;; ) {
     85    tr_globalLock( handle );
     86
     87    while( !done )
     88    {
    8489        const int ret = (*c->canRead)( e, c->userData );
    85         switch( ret ) {
    86             case READ_AGAIN: if( EVBUFFER_LENGTH( e->input ) ) continue; /* note fall-through */
    87             case READ_MORE: tr_peerIoSetIOMode( c, EV_READ, 0 ); return; break;
    88             case READ_DONE: return;
     90
     91        switch( ret )
     92        {
     93            case READ_AGAIN:
     94                if( EVBUFFER_LENGTH( e->input ) )
     95                    continue;
     96            case READ_MORE:
     97                tr_peerIoSetIOMode( c, EV_READ, 0 );
     98            case READ_DONE:
     99                done = 1;
    89100        }
    90101    }
     102
     103    tr_globalUnlock( handle );
    91104}
    92105
  • trunk/libtransmission/torrent.c

    r3258 r3267  
    10451045}
    10461046
    1047 static void
    1048 tr_torrentStopImpl( void * vtor )
    1049 {
    1050     tr_torrent * tor = vtor;
     1047void
     1048tr_torrentStop( tr_torrent * tor )
     1049{
     1050    tr_globalLock( tor->handle );
    10511051
    10521052    switch( tor->runStatus )
     
    10701070            break;
    10711071    }
    1072 }
    1073 
    1074 void
    1075 tr_torrentStop( tr_torrent * tor )
    1076 {
    1077     tr_torrentStopImpl( tor );
     1072
     1073    tr_globalUnlock( tor->handle );
    10781074}
    10791075
     
    10811077tr_torrentClose( tr_torrent * tor )
    10821078{
     1079    tr_globalLock( tor->handle );
     1080
    10831081    tor->runStatusToSave = tor->runStatus;
    10841082    tor->runStatusToSaveIsSet = TRUE;
    10851083    tr_torrentStop( tor );
    10861084    tr_timerNew( tor->handle, freeWhenStopped, tor, 250 );
     1085
     1086    tr_globalUnlock( tor->handle );
    10871087}
    10881088
Note: See TracChangeset for help on using the changeset viewer.