Correct path MTU discovery

This commit is contained in:
Keith Winstein
2011-08-03 21:35:48 -04:00
parent 7ea81ca237
commit b84599f263
2 changed files with 12 additions and 6 deletions
+11 -5
View File
@@ -130,19 +130,25 @@ void Connection<Outgoing, Incoming>::client_connect( const char *ip, int port )
}
template <class Outgoing, class Incoming>
void Connection<Outgoing, Incoming>::send( Outgoing &s )
bool Connection<Outgoing, Incoming>::send( Outgoing &s )
{
assert( attached );
string p = flow.new_packet( s ).tostring();
if ( sendto( sock, p.data(), p.size(), 0,
(sockaddr *)&remote_addr, sizeof( remote_addr ) ) < 0 ) {
ssize_t bytes_sent = sendto( sock, p.data(), p.size(), 0,
(sockaddr *)&remote_addr, sizeof( remote_addr ) );
if ( (bytes_sent < 0) && (errno == EMSGSIZE) ) {
update_MTU();
return false;
} else if ( bytes_sent == static_cast<int>( p.size() ) ) {
return true;
} else {
perror( "sendto" );
exit( 1 );
return false;
}
update_MTU();
}
template <class Outgoing, class Incoming>