summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-08-11 18:43:28 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-08-11 18:43:28 +0200
commitd6c5a5a52310ea05205a599709990bf6bee0499a (patch)
treeb18147eb215de7484e97fb5afe789cbf3ec95110 /cpp/src
parentAdd SDK prefix to WinRT builds (diff)
downloadice-d6c5a5a52310ea05205a599709990bf6bee0499a.tar.bz2
ice-d6c5a5a52310ea05205a599709990bf6bee0499a.tar.xz
ice-d6c5a5a52310ea05205a599709990bf6bee0499a.zip
Fixed ICE-6695 - ensure buffers are not cleared too early for WS/SSL transports
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/StreamSocket.cpp9
-rw-r--r--cpp/src/Ice/WSTransceiver.cpp24
2 files changed, 29 insertions, 4 deletions
diff --git a/cpp/src/Ice/StreamSocket.cpp b/cpp/src/Ice/StreamSocket.cpp
index 7ade8172ba4..8eb3a23daf9 100644
--- a/cpp/src/Ice/StreamSocket.cpp
+++ b/cpp/src/Ice/StreamSocket.cpp
@@ -105,7 +105,7 @@ StreamSocket::connect(Buffer& readBuffer, Buffer& writeBuffer)
bool
StreamSocket::isConnected()
{
- return _state == StateConnected;
+ return _state == StateConnected && _fd != INVALID_SOCKET;
}
size_t
@@ -377,7 +377,7 @@ StreamSocket::startWrite(Buffer& buf)
void
StreamSocket::finishWrite(Buffer& buf)
{
- if(_state < StateConnected && _state != StateProxyWrite)
+ if(_fd == INVALID_SOCKET || (_state < StateConnected && _state != StateProxyWrite))
{
return;
}
@@ -439,6 +439,11 @@ StreamSocket::startRead(Buffer& buf)
void
StreamSocket::finishRead(Buffer& buf)
{
+ if(_fd == INVALID_SOCKET)
+ {
+ return;
+ }
+
if(static_cast<int>(_read.count) == SOCKET_ERROR)
{
WSASetLastError(_read.error);
diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp
index a7f85a0e8bd..e68bccc4668 100644
--- a/cpp/src/Ice/WSTransceiver.cpp
+++ b/cpp/src/Ice/WSTransceiver.cpp
@@ -482,8 +482,14 @@ IceInternal::WSTransceiver::close()
//
// Clear the buffers now instead of waiting for destruction.
//
- _writeBuffer.b.clear();
- _readBuffer.b.clear();
+ if(!_writePending)
+ {
+ _writeBuffer.b.clear();
+ }
+ if(!_readPending)
+ {
+ _readBuffer.b.clear();
+ }
}
SocketOperation
@@ -677,6 +683,7 @@ void
IceInternal::WSTransceiver::finishWrite(Buffer& buf)
{
_writePending = false;
+
if(_state < StateOpened)
{
if(_state < StateConnected)
@@ -700,6 +707,12 @@ IceInternal::WSTransceiver::finishWrite(Buffer& buf)
_delegate->finishWrite(buf);
}
+ if(_state == StateClosed)
+ {
+ _writeBuffer.b.clear();
+ return;
+ }
+
postWrite(buf);
}
@@ -782,6 +795,13 @@ IceInternal::WSTransceiver::finishRead(Buffer& buf, bool& hasMoreData)
{
_delegate->finishRead(_readBuffer, hasMoreData);
}
+
+ if(_state == StateClosed)
+ {
+ _readBuffer.b.clear();
+ return;
+ }
+
postRead(buf);
}
#endif