diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Exception.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/Network.cpp | 27 | ||||
-rw-r--r-- | cpp/src/Ice/Network.h | 1 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslClientTransceiver.cpp | 12 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslServerTransceiver.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslTransceiver.cpp | 4 |
6 files changed, 42 insertions, 11 deletions
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index 848c7d5f83e..baa83eab316 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -205,6 +205,13 @@ Ice::ConnectFailedException::ice_print(ostream& out) const } void +Ice::ConnectionRefusedException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ":\nconnection refused: " << errorToString(error); +} + +void Ice::ConnectionLostException::ice_print(ostream& out) const { Exception::ice_print(out); diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 3512f7e0633..2924f8aeee4 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -101,6 +101,17 @@ IceInternal::connectFailed() } bool +IceInternal::connectionRefused() +{ +#ifdef _WIN32 + int error = WSAGetLastError(); + return error == WSAECONNREFUSED; +#else + return errno == ECONNREFUSED; +#endif +} + +bool IceInternal::connectInProgress() { #ifdef _WIN32 @@ -484,7 +495,13 @@ repeatConnect: #else errno = val; #endif - if(connectFailed()) + if(connectionRefused()) + { + ConnectionRefusedException ex(__FILE__, __LINE__); + ex.error = getSocketErrno(); + throw ex; + } + else if(connectFailed()) { ConnectFailedException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -502,7 +519,13 @@ repeatConnect: } closeSocket(fd); - if(connectFailed()) + if(connectionRefused()) + { + ConnectionRefusedException ex(__FILE__, __LINE__); + ex.error = getSocketErrno(); + throw ex; + } + else if(connectFailed()) { ConnectFailedException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index 83568571088..60362a24ef0 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -79,6 +79,7 @@ ICE_PROTOCOL_API bool acceptInterrupted(); ICE_PROTOCOL_API bool noBuffers(); ICE_PROTOCOL_API bool wouldBlock(); ICE_PROTOCOL_API bool connectFailed(); +ICE_PROTOCOL_API bool connectionRefused(); ICE_PROTOCOL_API bool connectInProgress(); ICE_PROTOCOL_API bool connectionLost(); ICE_PROTOCOL_API bool notConnected(); diff --git a/cpp/src/IceSSL/SslClientTransceiver.cpp b/cpp/src/IceSSL/SslClientTransceiver.cpp index 4deb7038700..ea90e1c54ef 100644 --- a/cpp/src/IceSSL/SslClientTransceiver.cpp +++ b/cpp/src/IceSSL/SslClientTransceiver.cpp @@ -284,14 +284,14 @@ IceSSL::SslClientTransceiver::handshake(int timeout) else // result == 0 { // - // The OpenSSL docs say that a result code of 0 indicates - // a graceful shutdown. In order to cause a retry in the - // Ice core, we raise ConnectFailedException. However, - // errno isn't set in this situation, so we always use + // The OpenSSL docs say that a result code of 0 + // indicates a graceful shutdown. In order to + // cause a retry in the Ice core, we raise + // ConnectionRefusedException. However, errno + // isn't set in this situation, so we always use // ECONNREFUSED. // - - ConnectFailedException ex(__FILE__, __LINE__); + ConnectionRefusedException ex(__FILE__, __LINE__); #ifdef _WIN32 ex.error = WSAECONNREFUSED; #else diff --git a/cpp/src/IceSSL/SslServerTransceiver.cpp b/cpp/src/IceSSL/SslServerTransceiver.cpp index 3a38180171b..bf05422c09d 100644 --- a/cpp/src/IceSSL/SslServerTransceiver.cpp +++ b/cpp/src/IceSSL/SslServerTransceiver.cpp @@ -287,7 +287,7 @@ IceSSL::SslServerTransceiver::handshake(int timeout) else { // - // NOTE: Should this be ConnectFailedException like in the Client? + // NOTE: Should this be ConnectionRefusedException like in the Client? // ProtocolException protocolEx(__FILE__, __LINE__); diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp index eb42d4d938f..d9595a4a37f 100644 --- a/cpp/src/IceSSL/SslTransceiver.cpp +++ b/cpp/src/IceSSL/SslTransceiver.cpp @@ -350,8 +350,8 @@ IceSSL::SslTransceiver::forceHandshake() close(); - // If the handshake fails, the connection failed. - ConnectFailedException ex(__FILE__, __LINE__); + // If the handshake fails, we consider the connection as refused. + ConnectionRefusedException ex(__FILE__, __LINE__); #ifdef _WIN32 ex.error = WSAECONNREFUSED; #else |