summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/SslTransceiver.cpp2
-rw-r--r--cpp/src/Ice/SslTransceiver.h2
-rw-r--r--cpp/src/Ice/TcpTransceiver.cpp4
-rw-r--r--cpp/src/Ice/TcpTransceiver.h2
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp62
-rw-r--r--cpp/src/Ice/UdpTransceiver.h2
6 files changed, 67 insertions, 7 deletions
diff --git a/cpp/src/Ice/SslTransceiver.cpp b/cpp/src/Ice/SslTransceiver.cpp
index 8d967b85765..fde1a13c9f1 100644
--- a/cpp/src/Ice/SslTransceiver.cpp
+++ b/cpp/src/Ice/SslTransceiver.cpp
@@ -89,9 +89,9 @@ IceInternal::SslTransceiver::SslTransceiver(const InstancePtr& instance,
SOCKET fd,
const ConnectionPtr& sslConnection) :
_instance(instance),
- _fd(fd),
_traceLevels(instance->traceLevels()),
_logger(instance->logger()),
+ _fd(fd),
_sslConnection(sslConnection)
{
assert(sslConnection != 0);
diff --git a/cpp/src/Ice/SslTransceiver.h b/cpp/src/Ice/SslTransceiver.h
index 840139124a1..492e30d7681 100644
--- a/cpp/src/Ice/SslTransceiver.h
+++ b/cpp/src/Ice/SslTransceiver.h
@@ -43,9 +43,9 @@ private:
friend class SslAcceptor;
InstancePtr _instance;
- SOCKET _fd;
TraceLevelsPtr _traceLevels;
::Ice::LoggerPtr _logger;
+ SOCKET _fd;
fd_set _rFdSet;
fd_set _wFdSet;
diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp
index 30ff76394d3..a0e8551d676 100644
--- a/cpp/src/Ice/TcpTransceiver.cpp
+++ b/cpp/src/Ice/TcpTransceiver.cpp
@@ -269,9 +269,9 @@ IceInternal::TcpTransceiver::toString() const
IceInternal::TcpTransceiver::TcpTransceiver(const InstancePtr& instance, SOCKET fd) :
_instance(instance),
- _fd(fd),
_traceLevels(instance->traceLevels()),
- _logger(instance->logger())
+ _logger(instance->logger()),
+ _fd(fd)
{
FD_ZERO(&_rFdSet);
FD_ZERO(&_wFdSet);
diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h
index 939ff3b13f9..9809f68a60b 100644
--- a/cpp/src/Ice/TcpTransceiver.h
+++ b/cpp/src/Ice/TcpTransceiver.h
@@ -41,9 +41,9 @@ private:
friend class TcpAcceptor;
InstancePtr _instance;
- SOCKET _fd;
TraceLevelsPtr _traceLevels;
::Ice::LoggerPtr _logger;
+ SOCKET _fd;
fd_set _rFdSet;
fd_set _wFdSet;
};
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index decb65b3acd..7e66fa78d81 100644
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -64,6 +64,32 @@ repeat:
goto repeat;
}
+ if (wouldBlock())
+ {
+ SOCKET fd = _fd; // Copy fd, in case another thread calls close()
+ if (fd != INVALID_SOCKET)
+ {
+ repeatSelect:
+
+ FD_SET(fd, &_wFdSet);
+ int ret = ::select(fd + 1, 0, &_wFdSet, 0, 0);
+
+ if (ret == SOCKET_ERROR)
+ {
+ if (interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ goto repeat;
+ }
+
SocketException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
throw ex;
@@ -124,6 +150,32 @@ repeat:
goto repeat;
}
+ if (wouldBlock())
+ {
+ SOCKET fd = _fd; // Copy fd, in case another thread calls close()
+ if (fd != INVALID_SOCKET)
+ {
+ repeatSelect:
+
+ FD_SET(fd, &_rFdSet);
+ int ret = ::select(fd + 1, &_rFdSet, 0, 0, 0);
+
+ if (ret == SOCKET_ERROR)
+ {
+ if (interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ goto repeat;
+ }
+
SocketException ex(__FILE__, __LINE__);
ex.error = getSocketErrno();
throw ex;
@@ -177,7 +229,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
try
{
_fd = createSocket(true);
- setBlock(_fd, true);
+ setBlock(_fd, false);
getAddress(host, port, _addr);
doConnect(_fd, _addr, -1);
_connect = false; // We're connected now
@@ -193,6 +245,9 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
_fd = INVALID_SOCKET;
throw;
}
+
+ FD_ZERO(&_rFdSet);
+ FD_ZERO(&_wFdSet);
}
IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const string& host, int port,
@@ -207,7 +262,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
try
{
_fd = createSocket(true);
- setBlock(_fd, true);
+ setBlock(_fd, false);
getAddress(host, port, _addr);
doBind(_fd, _addr);
@@ -222,6 +277,9 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
_fd = INVALID_SOCKET;
throw;
}
+
+ FD_ZERO(&_rFdSet);
+ FD_ZERO(&_wFdSet);
}
IceInternal::UdpTransceiver::~UdpTransceiver()
diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h
index 1b552f7e937..5a979dc9ac1 100644
--- a/cpp/src/Ice/UdpTransceiver.h
+++ b/cpp/src/Ice/UdpTransceiver.h
@@ -59,6 +59,8 @@ private:
bool _connect;
SOCKET _fd;
struct sockaddr_in _addr;
+ fd_set _rFdSet;
+ fd_set _wFdSet;
std::string _protocolName;
};