(trunk libT) #3162 "allow optional end-user configuration of TCP_CONGESTION" -- minor tweak removing a little bit of code duplication in r10508
This commit is contained in:
parent
00f452d942
commit
559af38e7b
|
@ -356,6 +356,19 @@ event_write_cb( int fd, short event UNUSED, void * vio )
|
|||
***
|
||||
**/
|
||||
|
||||
static void
|
||||
maybeSetCongestionAlgorithm( int socket, const char * algorithm )
|
||||
{
|
||||
if( algorithm && *algorithm )
|
||||
{
|
||||
const int rc = tr_netSetCongestionControl( socket, algorithm );
|
||||
|
||||
if( rc < 0 )
|
||||
tr_ninf( "Net", "Can't set congestion control algorithm '%s': %s",
|
||||
algorithm, tr_strerror( errno ));
|
||||
}
|
||||
}
|
||||
|
||||
static tr_peerIo*
|
||||
tr_peerIoNew( tr_session * session,
|
||||
tr_bandwidth * parent,
|
||||
|
@ -376,17 +389,7 @@ tr_peerIoNew( tr_session * session,
|
|||
|
||||
if( socket >= 0 ) {
|
||||
tr_netSetTOS( socket, session->peerSocketTOS );
|
||||
if( session->peer_congestion_algorithm &&
|
||||
session->peer_congestion_algorithm[0] ) {
|
||||
int rc;
|
||||
rc = tr_netSetCongestionControl( socket,
|
||||
session->peer_congestion_algorithm );
|
||||
if(rc < 0) {
|
||||
tr_ninf( "Net",
|
||||
"Couldn't set congestion control algorithm: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
maybeSetCongestionAlgorithm( socket, session->peer_congestion_algorithm );
|
||||
}
|
||||
|
||||
io = tr_new0( tr_peerIo, 1 );
|
||||
|
@ -658,18 +661,7 @@ tr_peerIoReconnect( tr_peerIo * io )
|
|||
if( io->socket >= 0 )
|
||||
{
|
||||
tr_netSetTOS( io->socket, session->peerSocketTOS );
|
||||
if( session->peer_congestion_algorithm &&
|
||||
session->peer_congestion_algorithm[0] ) {
|
||||
int rc;
|
||||
rc = tr_netSetCongestionControl( io->socket,
|
||||
session->peer_congestion_algorithm );
|
||||
if(rc < 0) {
|
||||
tr_ninf( "Net",
|
||||
"Couldn't set congestion control algorithm: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
maybeSetCongestionAlgorithm( io->socket, session->peer_congestion_algorithm );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue