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
The current implementation of the Tls.Stream async API (BeginRead, ReadAsync, etc) just schedules a task and calls the blocking non-async Read.
This causes most of the thread pool threads to be blocked with a stack similar to this one:
System.Net.Sockets.il!Interop+Winsock.recv(class System.Net.Sockets.SafeSocketHandle,unsigned int8*,int32,value class System.Net.Sockets.SocketFlags)
System.Net.Sockets.il!System.Net.Sockets.SocketPal.Receive(class System.Net.Sockets.SafeSocketHandle,value class System.Span`1<unsigned int8>,value class System.Net.Sockets.SocketFlags,int32&)
System.Net.Sockets.il!System.Net.Sockets.Socket.Receive(unsigned int8[],int32,int32,value class System.Net.Sockets.SocketFlags,value class System.Net.Sockets.SocketError&)
System.Net.Sockets.il!System.Net.Sockets.NetworkStream.Read(unsigned int8[],int32,int32)
BouncyCastle.Crypto!Org.BouncyCastle.Tls.RecordStream+Record.FillTo(class System.IO.Stream,int32)
BouncyCastle.Crypto!Org.BouncyCastle.Tls.RecordStream+Record.ReadHeader(class System.IO.Stream)
BouncyCastle.Crypto!Org.BouncyCastle.Tls.RecordStream.ReadRecord()
BouncyCastle.Crypto!Org.BouncyCastle.Tls.TlsProtocol.SafeReadRecord()
BouncyCastle.Crypto!Org.BouncyCastle.Tls.TlsProtocol.ReadApplicationData(unsigned int8[],int32,int32)
BouncyCastle.Crypto!Org.BouncyCastle.Tls.TlsStream.Read(unsigned int8[],int32,int32)
System.Private.CoreLib.il!System.IO.Stream+<>c.<BeginReadInternal>b__38_0(class System.Object)
System.Private.CoreLib.il!System.Threading.Tasks.Task`1[System.Int32].InnerInvoke()
System.Private.CoreLib.il!System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(class System.Threading.Thread,class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object)
System.Private.CoreLib.il!System.Threading.Tasks.Task.ExecuteWithThreadLocal(class System.Threading.Tasks.Task&,class System.Threading.Thread)
System.Private.CoreLib.il!System.Threading.ThreadPoolWorkQueue.Dispatch()
System.Private.CoreLib.il!System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
Is there a way to use the TlsStream in a non-blocking way? As far as I understand, BC would need to add proper implementation of the async apis for the TlsStream, TlsProtocol and RecordStream, which will use the Async APIs of the provided inner stream.
The text was updated successfully, but these errors were encountered:
The current implementation of the Tls.Stream async API (BeginRead, ReadAsync, etc) just schedules a task and calls the blocking non-async Read.
This causes most of the thread pool threads to be blocked with a stack similar to this one:
Is there a way to use the TlsStream in a non-blocking way? As far as I understand, BC would need to add proper implementation of the async apis for the TlsStream, TlsProtocol and RecordStream, which will use the Async APIs of the provided inner stream.
The text was updated successfully, but these errors were encountered: