Remove a Network::Exception that isn't one.

Code smell pointed out by Coverity.
This commit is contained in:
John Hood
2016-11-19 20:59:49 -05:00
parent 4fe706a4d3
commit 24eb5a7544
6 changed files with 25 additions and 33 deletions
+6 -12
View File
@@ -249,8 +249,7 @@ Connection::Connection( const char *desired_ip, const char *desired_port ) /* se
RTT_hit( false ),
SRTT( 1000 ),
RTTVAR( 500 ),
have_send_exception( false ),
send_exception()
send_error()
{
setup();
@@ -369,8 +368,7 @@ Connection::Connection( const char *key_str, const char *ip, const char *port )
RTT_hit( false ),
SRTT( 1000 ),
RTTVAR( 500 ),
have_send_exception( false ),
send_exception()
send_error()
{
setup();
@@ -405,14 +403,10 @@ void Connection::send( const string & s )
ssize_t bytes_sent = sendto( sock(), p.data(), p.size(), MSG_DONTWAIT,
&remote_addr.sa, remote_addr_len );
if ( bytes_sent == static_cast<ssize_t>( p.size() ) ) {
have_send_exception = false;
} else {
/* Notify the frontend on sendto() failure, but don't alter control flow.
sendto() success is not very meaningful because packets can be lost in
flight anyway. */
have_send_exception = true;
send_exception = NetworkException( "sendto", errno );
if ( bytes_sent != static_cast<ssize_t>( p.size() ) ) {
/* Make sendto() failure available to the frontend. */
send_error = "sendto: ";
send_error += strerror( errno );
if ( errno == EMSGSIZE ) {
MTU = DEFAULT_SEND_MTU; /* payload MTU of last resort */
+4 -6
View File
@@ -187,10 +187,8 @@ namespace Network {
double SRTT;
double RTTVAR;
/* Exception from send(), to be delivered if the frontend asks for it,
without altering control flow. */
bool have_send_exception;
NetworkException send_exception;
/* Error from send()/sendto(). */
string send_error;
Packet new_packet( const string &s_payload );
@@ -226,9 +224,9 @@ namespace Network {
const Addr &get_remote_addr( void ) const { return remote_addr; }
socklen_t get_remote_addr_len( void ) const { return remote_addr_len; }
const NetworkException *get_send_exception( void ) const
string &get_send_error( void )
{
return have_send_exception ? &send_exception : NULL;
return send_error;
}
void set_last_roundtrip_success( uint64_t s_success ) { last_roundtrip_success = s_success; }
+1 -1
View File
@@ -119,7 +119,7 @@ namespace Network {
const Addr &get_remote_addr( void ) const { return connection.get_remote_addr(); }
socklen_t get_remote_addr_len( void ) const { return connection.get_remote_addr_len(); }
const NetworkException *get_send_exception( void ) const { return connection.get_send_exception(); }
std::string &get_send_error( void ) { return connection.get_send_error(); }
};
}