summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-01-18 15:27:24 +0000
committerMarc Laukien <marc@zeroc.com>2004-01-18 15:27:24 +0000
commitf2453dff9bbdb644fce74474e2659e75298187ae (patch)
tree39fbc2856b12abf6a97857b5832f36810cb98f22 /cpp/src
parentminor (diff)
downloadice-f2453dff9bbdb644fce74474e2659e75298187ae.tar.bz2
ice-f2453dff9bbdb644fce74474e2659e75298187ae.tar.xz
ice-f2453dff9bbdb644fce74474e2659e75298187ae.zip
fix
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/TcpTransceiver.cpp19
-rw-r--r--cpp/src/IceSSL/SslTransceiver.cpp27
2 files changed, 46 insertions, 0 deletions
diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp
index b0196073949..6b57e537bff 100644
--- a/cpp/src/Ice/TcpTransceiver.cpp
+++ b/cpp/src/Ice/TcpTransceiver.cpp
@@ -193,6 +193,17 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout)
if(ret == 0)
{
+ //
+ // If the connection is lost when reading data, we shut
+ // down the write end of the socket. This helps to unblock
+ // threads that are stuck in send() or select() while
+ // sending data. Note: I don't really understand why
+ // send() or select() sometimes don't detect a connection
+ // loss. Therefore this helper to make them detect it.
+ //
+ assert(_fd != INVALID_SOCKET);
+ shutdownSocket(_fd);
+
ConnectionLostException ex(__FILE__, __LINE__);
ex.error = 0;
throw ex;
@@ -253,6 +264,14 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout)
if(connectionLost())
{
+ //
+ // See the commment above about shutting down the
+ // socket if the connection is lost while reading
+ // data.
+ //
+ assert(_fd != INVALID_SOCKET);
+ shutdownSocket(_fd);
+
ConnectionLostException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
throw ex;
diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp
index 6987ea1102d..c18256313dc 100644
--- a/cpp/src/IceSSL/SslTransceiver.cpp
+++ b/cpp/src/IceSSL/SslTransceiver.cpp
@@ -234,6 +234,17 @@ IceSSL::SslTransceiver::read(Buffer& buf, int timeout)
if(connectionLost())
{
+ //
+ // If the connection is lost when reading data, we shut
+ // down the write end of the socket. This helps to unblock
+ // threads that are stuck in send() or select() while
+ // sending data. Note: I don't really understand why
+ // send() or select() sometimes don't detect a connection
+ // loss. Therefore this helper to make them detect it.
+ //
+ assert(_fd != INVALID_SOCKET);
+ shutdownSocket(_fd);
+
ConnectionLostException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
throw ex;
@@ -245,6 +256,14 @@ IceSSL::SslTransceiver::read(Buffer& buf, int timeout)
}
else // (bytesRead == 0)
{
+ //
+ // See the commment above about shutting down the
+ // socket if the connection is lost while reading
+ // data.
+ //
+ assert(_fd != INVALID_SOCKET);
+ shutdownSocket(_fd);
+
ConnectionLostException ex(__FILE__, __LINE__);
ex.error = 0;
throw ex;
@@ -263,6 +282,14 @@ IceSSL::SslTransceiver::read(Buffer& buf, int timeout)
case SSL_ERROR_ZERO_RETURN:
{
+ //
+ // See the commment above about shutting down the
+ // socket if the connection is lost while reading
+ // data.
+ //
+ assert(_fd != INVALID_SOCKET);
+ shutdownSocket(_fd);
+
// Indicates that that the SSL Connection has been closed.
// But does not necessarily indicate that the underlying transport
// has been closed (in the case of Ice, it definitely hasn't yet).