Changeset 11951


Ignore:
Timestamp:
Feb 18, 2011, 12:43:34 AM (11 years ago)
Author:
jch
Message:

When failing to connect over uTP, fall back to TCP.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r11881 r11951  
    11251125
    11261126static void
    1127 gotError( tr_peerIo  * io UNUSED,
     1127gotError( tr_peerIo  * io,
    11281128          short        what,
    11291129          void       * vhandshake )
    11301130{
    11311131    tr_handshake * handshake = vhandshake;
     1132
     1133    if( io->utp_socket && !io->isIncoming && handshake->state == AWAITING_YB ) {
     1134        /* This peer probably doesn't speak uTP. */
     1135        tr_torrent *tor =
     1136            tr_peerIoHasTorrentHash( io ) ?
     1137            tr_torrentFindFromHash( handshake->session,
     1138                                    tr_peerIoGetTorrentHash( io ) ) :
     1139            NULL;
     1140        if( tor ) {
     1141            tr_torrentLock( tor );
     1142            tr_peerMgrSetUtpFailed( tor,
     1143                                    tr_peerIoGetAddress( io, NULL ),
     1144                                    TRUE );
     1145            tr_torrentUnlock( tor );
     1146        } else {
     1147            tr_nerr( "UTP", "Eek -- couldn't find torrent for outgoing I/O." );
     1148        }
     1149
     1150        if( !tr_peerIoReconnect( handshake->io ) ) {
     1151            uint8_t msg[HANDSHAKE_SIZE];
     1152            buildHandshakeMessage( handshake, msg );
     1153            handshake->haveSentBitTorrentHandshake = 1;
     1154            setReadState( handshake, AWAITING_HANDSHAKE );
     1155            tr_peerIoWriteBytes( handshake->io, msg, sizeof( msg ), FALSE );
     1156        }
     1157    }
    11321158
    11331159    /* if the error happened while we were sending a public key, we might
  • trunk/libtransmission/peer-msgs.c

    r11946 r11951  
    23822382        const tr_address * addr = tr_peerIoGetAddress( peer->io, NULL );
    23832383        tr_peerMgrSetUtpSupported( torrent, addr );
     2384        tr_peerMgrSetUtpFailed( torrent, addr, FALSE );
    23842385    }
    23852386
Note: See TracChangeset for help on using the changeset viewer.