Changeset 6415


Ignore:
Timestamp:
Jul 29, 2008, 12:52:02 AM (13 years ago)
Author:
charles
Message:

#1123: unreachable peers need to be handled better

Location:
trunk/libtransmission
Files:
3 edited

Legend:

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

    r6334 r6415  
    6969
    7070    tr_crypto           * crypto;
     71
     72    uint64_t              fromPeer;
    7173};
    7274
     
    538540    {
    539541        case PEER_ENCRYPTION_NONE:
    540             evbuffer_remove( inbuf, bytes, byteCount );
     542            io->fromPeer += evbuffer_remove( inbuf, bytes, byteCount );
    541543            break;
    542544
    543545        case PEER_ENCRYPTION_RC4:
    544             evbuffer_remove( inbuf, bytes, byteCount );
     546            io->fromPeer += evbuffer_remove( inbuf, bytes, byteCount );
    545547            tr_cryptoDecrypt( io->crypto, byteCount, bytes, bytes );
    546548            break;
     
    594596    return time( NULL ) - io->timeCreated;
    595597}
     598
     599int64_t
     600tr_peerIoCountBytesFromPeer( const tr_peerIo * io )
     601{
     602    return io->fromPeer;
     603}
     604
  • trunk/libtransmission/peer-io.h

    r5917 r6415  
    179179                            size_t             byteCount );
    180180
     181int64_t tr_peerIoCountBytesFromPeer( const tr_peerIo * io );
    181182
    182183#endif
  • trunk/libtransmission/peer-mgr.c

    r6406 r6415  
    4545
    4646    /* minimum interval for refilling peers' request lists */
    47     REFILL_PERIOD_MSEC = 333,
     47    REFILL_PERIOD_MSEC = 500,
    4848
    4949    /* when many peers are available, keep idle ones this long */
     
    966966            struct peer_atom * atom = getExistingAtom( t, addr );
    967967            if( atom )
    968                 ++atom->numFails;
     968            {
     969                /* if we talked but the connection failed, mark a failure
     970                 * in the peer's permanent record.  if they didn't send
     971                 * us anything at all, mark the peer as unreachable. */
     972                if( tr_peerIoCountBytesFromPeer( io ) ) {
     973                    ++atom->numFails;
     974                    tordbg( t, "handshake failed; incremented fail count to %d", (int)atom->numFails );
     975                } else {
     976                    tordbg( t, "no data received at all during handshake; marking as unreachable" );
     977                    atom->myflags |= MYFLAG_UNREACHABLE;
     978                }
     979            }
    969980        }
    970981
     
    18151826            if( wait > maxWait ) wait = maxWait;
    18161827            if( ( now - atom->time ) < wait ) {
    1817                 tordbg( t, "RECONNECT peer %d (%s) is in its grace period of %d seconds..",
    1818                         i, tr_peerIoAddrStr(&atom->addr,atom->port), wait );
     1828                /*tordbg( t, "RECONNECT peer %d (%s) is in its grace period of %d seconds..",
     1829                          i, tr_peerIoAddrStr(&atom->addr,atom->port), wait );*/
    18191830                continue;
    18201831            }
     
    18961907            if( io == NULL )
    18971908            {
    1898                 atom->myflags |= MYFLAG_UNREACHABLE;
     1909                /* we've temporarily exceeded our max connection limit... */
    18991910            }
    19001911            else
Note: See TracChangeset for help on using the changeset viewer.