Merge pull request #160 from vibe-d/leastsize_timeout

Let TCPConnection.leastSize time out according to the readTimeout property
merged-on-behalf-of: Leonid Kramer <l-kramer@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2019-06-16 15:06:05 +02:00 committed by GitHub
commit b68c8b12f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -553,7 +553,18 @@ struct TCPConnection {
return s >= ConnectionState.connected && s < ConnectionState.activeClose;
}
@property bool empty() { return leastSize == 0; }
@property ulong leastSize() { waitForData(); return m_context ? m_context.readBuffer.length : 0; }
@property ulong leastSize()
{
if (!m_context) return 0;
auto res = waitForDataEx(m_context.readTimeout);
if (res == WaitForDataStatus.timeout)
throw new ReadTimeoutException("Read operation timed out");
return m_context.readBuffer.length;
}
@property bool dataAvailableForRead() { return waitForData(0.seconds); }
void close()