diff options
Diffstat (limited to 'cpp/src/IceSSL')
-rw-r--r-- | cpp/src/IceSSL/OpenSSLTransceiverI.cpp | 7 | ||||
-rw-r--r-- | cpp/src/IceSSL/SecureTransportTransceiverI.cpp | 21 |
2 files changed, 19 insertions, 9 deletions
diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp index 7503cc8c9a8..d66c5eb2781 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp @@ -440,7 +440,7 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) } IceInternal::SocketOperation -IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) +IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool& hasMoreData) { if(!_stream->isConnected()) { @@ -548,6 +548,11 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) } } + // + // Check if there's still buffered data to read. In this case, set hasMoreData to true. + // + hasMoreData = SSL_pending(_ssl) > 0; + return IceInternal::SocketOperationNone; } diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp index 3b532b059fc..2b4dff3ab25 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -396,20 +396,13 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) } IceInternal::SocketOperation -IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) +IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool& hasMoreData) { if(!_stream->isConnected()) { return _stream->read(buf); } - // - // Note: we don't set the hasMoreData flag in this implementation. - // We assume that SecureTransport doesn't read more SSL records - // than necessary to fill the requested data and that the sender - // sends Ice messages in individual SSL records. - // - if(buf.i == buf.b.end()) { return IceInternal::SocketOperationNone; @@ -461,6 +454,18 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) packetSize = buf.b.end() - buf.i; } } + + // + // Check if there's still buffered data to read. In this case, set hasMoreData to true. + // + size_t buffered = 0; + OSStatus err = SSLGetBufferedReadSize(_ssl, &buffered); + if(err) + { + errno = err; + throw SocketException(__FILE__, __LINE__, IceInternal::getSocketErrno()); + } + hasMoreData = buffered > 0; return IceInternal::SocketOperationNone; } |