Correct path MTU discovery
This commit is contained in:
+11
-5
@@ -130,19 +130,25 @@ void Connection<Outgoing, Incoming>::client_connect( const char *ip, int port )
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Outgoing, class Incoming>
|
template <class Outgoing, class Incoming>
|
||||||
void Connection<Outgoing, Incoming>::send( Outgoing &s )
|
bool Connection<Outgoing, Incoming>::send( Outgoing &s )
|
||||||
{
|
{
|
||||||
assert( attached );
|
assert( attached );
|
||||||
|
|
||||||
string p = flow.new_packet( s ).tostring();
|
string p = flow.new_packet( s ).tostring();
|
||||||
|
|
||||||
if ( sendto( sock, p.data(), p.size(), 0,
|
ssize_t bytes_sent = sendto( sock, p.data(), p.size(), 0,
|
||||||
(sockaddr *)&remote_addr, sizeof( remote_addr ) ) < 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" );
|
perror( "sendto" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_MTU();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Outgoing, class Incoming>
|
template <class Outgoing, class Incoming>
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ namespace Network {
|
|||||||
Connection( bool s_server );
|
Connection( bool s_server );
|
||||||
|
|
||||||
void client_connect( const char *ip, int port );
|
void client_connect( const char *ip, int port );
|
||||||
void send( Outgoing &s );
|
bool send( Outgoing &s );
|
||||||
Incoming recv( void );
|
Incoming recv( void );
|
||||||
int fd( void ) { return sock; }
|
int fd( void ) { return sock; }
|
||||||
int port( void );
|
int port( void );
|
||||||
|
|||||||
Reference in New Issue
Block a user