You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Take steps to avoid threadpool starvation (#11275)
Fixes #
### Context
There are a handful of areas where threadpool threads are unnecessarily
blocked by synchronous work, or there is additional contention that can
be avoided. The most egregious instance is the synchronous read in
BuferedReadStream

The outer call to BeginRead() ends up calling BufferedReadStream.Read()
which synchronously blocks when _innerStream.Read() is called. This
results in a substantial amount of block time for threadpool threads.
### Changes Made
### Testing
### Notes
thrownewInvalidOperationException(String.Format(CultureInfo.InvariantCulture,"Client: rejected old host. Received byte {0} instead of {1}.",bytes[0],byteToAccept));
thrownew InvalidOperationException(String.Format(CultureInfo.InvariantCulture,"Client: rejected old host. Received byte {0} instead of {1}.",bytes[0],byteToAccept));
562
-
}
553
+
if(bytesRead != bytes.Length)
554
+
{
555
+
// We've unexpectly reached end of stream.
556
+
// We are now in a bad state, disconnect on our end
557
+
thrownew IOException(String.Format(CultureInfo.InvariantCulture,"Unexpected end of stream while reading for handshake"));
0 commit comments