Changeset 10508


Ignore:
Timestamp:
Apr 22, 2010, 1:49:16 AM (11 years ago)
Author:
charles
Message:

(trunk libT) #3162 "allow optional end-user configuration of TCP_CONGESTION" -- add jch's implementation of this to trunk for 2.00

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.c

    r10498 r10508  
    3636 #include <WS2tcpip.h>
    3737#else
     38 #include <sys/socket.h>
     39 #include <netinet/in.h>
     40 #include <netinet/tcp.h>
    3841 #include <arpa/inet.h> /* inet_addr */
    3942 #include <netdb.h>
     
    208211#else
    209212    return 0;
     213#endif
     214}
     215
     216int
     217tr_netSetCongestionControl( int s, const char *algorithm )
     218{
     219#ifdef TCP_CONGESTION
     220    return setsockopt( s, IPPROTO_TCP, TCP_CONGESTION,
     221                       algorithm, strlen(algorithm) + 1 );
     222#else
     223    errno = ENOSYS;
     224    return -1;
    210225#endif
    211226}
  • trunk/libtransmission/net.h

    r10018 r10508  
    116116                   int tos );
    117117
     118int tr_netSetCongestionControl( int s, const char *algorithm );
     119
    118120void tr_netClose( tr_session * session, int s );
    119121
  • trunk/libtransmission/peer-io.c

    r10300 r10508  
    375375    assert( tr_amInEventThread( session ) );
    376376
    377     if( socket >= 0 )
     377    if( socket >= 0 ) {
    378378        tr_netSetTOS( socket, session->peerSocketTOS );
    379 
     379        if( session->peer_congestion_algorithm &&
     380            session->peer_congestion_algorithm[0] ) {
     381            int rc;
     382            rc = tr_netSetCongestionControl( socket,
     383                                             session->peer_congestion_algorithm );
     384            if(rc < 0) {
     385                tr_ninf( "Net",
     386                         "Couldn't set congestion control algorithm: %s\n",
     387                         strerror(errno));
     388            }
     389        }
     390    }
     391   
    380392    io = tr_new0( tr_peerIo, 1 );
    381393    io->magicNumber = MAGIC_NUMBER;
     
    647659    {
    648660        tr_netSetTOS( io->socket, session->peerSocketTOS );
     661        if( session->peer_congestion_algorithm &&
     662            session->peer_congestion_algorithm[0] ) {
     663            int rc;
     664            rc = tr_netSetCongestionControl( io->socket,
     665                                             session->peer_congestion_algorithm );
     666            if(rc < 0) {
     667                tr_ninf( "Net",
     668                         "Couldn't set congestion control algorithm: %s\n",
     669                         strerror(errno));
     670            }
     671        }
     672
    649673        return 0;
    650674    }
  • trunk/libtransmission/session.c

    r10485 r10508  
    323323    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_PORT_RANDOM_HIGH,    s->randomPortHigh );
    324324    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_SOCKET_TOS,          s->peerSocketTOS );
     325    if(s->peer_congestion_algorithm && s->peer_congestion_algorithm[0])
     326        tr_bencDictAddStr ( d, TR_PREFS_KEY_PEER_CONGESTION_ALGORITHM, s->peer_congestion_algorithm );
    325327    tr_bencDictAddBool( d, TR_PREFS_KEY_PEX_ENABLED,              s->isPexEnabled );
    326328    tr_bencDictAddBool( d, TR_PREFS_KEY_PORT_FORWARDING,          tr_sessionIsPortForwardingEnabled( s ) );
     
    669671    if( tr_bencDictFindInt( settings, TR_PREFS_KEY_PEER_SOCKET_TOS, &i ) )
    670672        session->peerSocketTOS = i;
     673    if( tr_bencDictFindStr( settings, TR_PREFS_KEY_PEER_CONGESTION_ALGORITHM, &str ) )
     674        session->peer_congestion_algorithm = tr_strdup(str);
    671675    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_BLOCKLIST_ENABLED, &boolVal ) )
    672676        tr_blocklistSetEnabled( session, boolVal );
     
    16571661    tr_free( session->proxyUsername );
    16581662    tr_free( session->proxyPassword );
     1663    tr_free( session->peer_congestion_algorithm );
    16591664    tr_free( session );
    16601665}
  • trunk/libtransmission/session.h

    r10391 r10508  
    125125    int                          proxyPort;
    126126    int                          peerSocketTOS;
     127    char *                       peer_congestion_algorithm;
    127128
    128129    int                          torrentCount;
  • trunk/libtransmission/transmission.h

    r10477 r10508  
    179179#define TR_PREFS_KEY_PEER_PORT_RANDOM_HIGH      "peer-port-random-high"
    180180#define TR_PREFS_KEY_PEER_SOCKET_TOS            "peer-socket-tos"
     181#define TR_PREFS_KEY_PEER_CONGESTION_ALGORITHM  "peer-congestion-algorithm"
    181182#define TR_PREFS_KEY_PEX_ENABLED                "pex-enabled"
    182183#define TR_PREFS_KEY_PORT_FORWARDING            "port-forwarding-enabled"
Note: See TracChangeset for help on using the changeset viewer.