summaryrefslogtreecommitdiff
path: root/src/SocketCore.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-01-30 00:17:54 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-01-30 00:17:54 +0900
commitcf2fa33fe0d73f7001d262beee5e8aba03544126 (patch)
tree338c442bac72e4ea7920970de6bc122b3485ad68 /src/SocketCore.cc
parent96247475315f6373c31f53bb658c7d59f48e8171 (diff)
WinTLS: Fix hang because of buffered received data
WinTLSSession buffers received decrypted data into its own buffer. If read is requested, it copies the data from its buffer. But if requested buffer size is less than decrypted buffer, some of the data is left in the buffer. Previously, we had no facility to check the existence of this pending data. If this data is the last requested data from remote server, we may end up waiting for read event even if we have already data in our buffer, which may cause hang. This commit fixes this issue by introducing function to return the buffered length in TLSSession. SocketCore also provides the same function, which delegates to TLSSession object.
Diffstat (limited to 'src/SocketCore.cc')
-rw-r--r--src/SocketCore.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/SocketCore.cc b/src/SocketCore.cc
index 50e974f5..3f04ee54 100644
--- a/src/SocketCore.cc
+++ b/src/SocketCore.cc
@@ -1324,6 +1324,15 @@ void SocketCore::setSocketRecvBufferSize(int size)
int SocketCore::getSocketRecvBufferSize() { return socketRecvBufferSize_; }
+size_t SocketCore::getRecvBufferedLength() const
+{
+ if (!tlsSession_) {
+ return 0;
+ }
+
+ return tlsSession_->getRecvBufferedLength();
+}
+
std::vector<SockAddr> SocketCore::getInterfaceAddress(const std::string& iface,
int family, int aiFlags)
{