Changeset 3231


Ignore:
Timestamp:
Sep 29, 2007, 1:47:15 PM (14 years ago)
Author:
charles
Message:

prevent a deadlock via the handshake code

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r3228 r3231  
    2727#include "handshake.h"
    2828#include "peer-io.h"
     29#include "trevent.h"
    2930#include "utils.h"
    3031
     
    123124    handshakeDoneCB doneCB;
    124125    void * doneUserData;
     126    tr_timer * startTimer;
    125127};
    126128
     
    10081010    dbgmsg( handshake, "handshakeDone: %s", isOK ? "connected" : "aborting" );
    10091011    tr_peerIoSetIOFuncs( handshake->io, NULL, NULL, NULL, NULL );
     1012
    10101013    fireDoneFunc( handshake, isOK );
     1014
     1015    tr_timerFree( &handshake->startTimer );
    10111016    tr_free( handshake );
    10121017}
     
    10481053**/
    10491054
     1055static int
     1056handshakeStart( void * vhandshake )
     1057{
     1058    tr_handshake * handshake = vhandshake;
     1059   
     1060    tr_peerIoSetIOMode( handshake->io, EV_READ|EV_WRITE, 0 );
     1061    tr_peerIoSetIOFuncs( handshake->io, canRead, NULL, gotError, handshake );
     1062
     1063    if( tr_peerIoIsIncoming( handshake->io ) )
     1064        setReadState( handshake, AWAITING_HANDSHAKE );
     1065    else
     1066        sendYa( handshake );
     1067
     1068    handshake->startTimer = 0;
     1069    return FALSE;
     1070}
     1071
    10501072tr_handshake*
    10511073tr_handshakeNew( tr_peerIo           * io,
     
    10551077{
    10561078    tr_handshake * handshake;
    1057 
    1058 // w00t
    1059 //static int count = 0;
    1060 //if( count++ ) return NULL;
    10611079
    10621080    handshake = tr_new0( tr_handshake, 1 );
     
    10681086    handshake->handle = tr_peerIoGetHandle( io );
    10691087
    1070     tr_peerIoSetIOMode( io, EV_READ|EV_WRITE, 0 );
    1071     tr_peerIoSetIOFuncs( io, canRead, NULL, gotError, handshake );
    1072 
    1073 dbgmsg( handshake, "new handshake for io %p", io );
    1074 
    1075     if( tr_peerIoIsIncoming( io ) )
    1076         setReadState( handshake, AWAITING_HANDSHAKE );
    1077     else
    1078         sendYa( handshake );
     1088    handshake->startTimer = tr_timerNew( handshake->handle,
     1089                                         handshakeStart,
     1090                                         handshake,
     1091                                         1000 );
    10791092
    10801093    return handshake;
  • trunk/libtransmission/peer-mgr.c

    r3230 r3231  
    144144}
    145145
    146 /* #define managerLock(a) fprintf(stderr,"%s:%d locking\n",__FILE__,__LINE__); managerLock(a); */
     146#define managerLock(a) fprintf(stderr,"%s:%d locking\n",__FILE__,__LINE__); managerLock(a);
    147147
    148148/**
Note: See TracChangeset for help on using the changeset viewer.