{
private readonly HttpConnectionPool _pool;
private readonly SslStream _stream;
- private readonly object _syncObject;
// NOTE: These are mutable structs; do not make these readonly.
private ArrayBuffer _incomingBuffer;
{
_pool = pool;
_stream = stream;
- _syncObject = new object();
_incomingBuffer = new ArrayBuffer(InitialConnectionBufferSize);
_outgoingBuffer = new ArrayBuffer(InitialConnectionBufferSize);
_headerBuffer = new ArrayBuffer(InitialConnectionBufferSize);
_maxConcurrentStreams = int.MaxValue;
}
+ private object SyncObject => _httpStreams;
+
public async Task SetupAsync()
{
_outgoingBuffer.EnsureAvailableSpace(s_http2ConnectionPreface.Length +
throw new Http2ProtocolException(Http2ProtocolErrorCode.ProtocolError);
}
- lock (_syncObject)
+ lock (SyncObject)
{
if (!_httpStreams.TryGetValue(streamId, out Http2Stream http2Stream))
{
{
Debug.Assert(newSize >= 0);
- lock (_syncObject)
+ lock (SyncObject)
{
int delta = newSize - _initialWindowSize;
_initialWindowSize = newSize;
private void AbortStreams(int lastValidStream)
{
- lock (_syncObject)
+ lock (SyncObject)
{
if (!_disposed)
{
private void CheckForShutdown()
{
Debug.Assert(_disposed);
- Debug.Assert(Monitor.IsEntered(_syncObject));
+ Debug.Assert(Monitor.IsEntered(SyncObject));
// Check if dictionary has become empty
if (_httpStreams.Count != 0)
public void Dispose()
{
- lock (_syncObject)
+ lock (SyncObject)
{
if (!_disposed)
{
private Http2Stream AddStream(HttpRequestMessage request)
{
- lock (_syncObject)
+ lock (SyncObject)
{
if (_disposed || _nextStream == MaxStreamId)
{
private void RemoveStream(Http2Stream http2Stream)
{
- lock (_syncObject)
+ lock (SyncObject)
{
if (!_httpStreams.Remove(http2Stream.StreamId, out Http2Stream removed))
{