Skip to content

Commit 0947ed9

Browse files
Plinermichaelklishin
authored andcommitted
Delete AutoClose from SessionManager
1 parent d1f0e45 commit 0947ed9

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

projects/RabbitMQ.Client/client/impl/SessionManager.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,8 @@
3838
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
3939
//---------------------------------------------------------------------------
4040

41-
using System;
4241
using System.Collections.Generic;
43-
using System.Threading;
44-
using System.Threading.Tasks;
45-
4642
using RabbitMQ.Client.Exceptions;
47-
using RabbitMQ.Client.Framing;
4843
using RabbitMQ.Client.Framing.Impl;
4944
using RabbitMQ.Util;
5045

@@ -56,7 +51,6 @@ class SessionManager
5651
private readonly IntAllocator _ints;
5752
private readonly Connection _connection;
5853
private readonly Dictionary<int, ISession> _sessionMap = new Dictionary<int, ISession>();
59-
private bool _autoClose = false;
6054

6155
public SessionManager(Connection connection, ushort channelMax)
6256
{
@@ -65,17 +59,6 @@ public SessionManager(Connection connection, ushort channelMax)
6559
_ints = new IntAllocator(1, ChannelMax);
6660
}
6761

68-
[Obsolete("Please explicitly close connections instead.")]
69-
public bool AutoClose
70-
{
71-
get { return _autoClose; }
72-
set
73-
{
74-
_autoClose = value;
75-
CheckAutoClose();
76-
}
77-
}
78-
7962
public int Count
8063
{
8164
get
@@ -87,38 +70,6 @@ public int Count
8770
}
8871
}
8972

90-
///<summary>Called from CheckAutoClose, in a separate thread,
91-
///when we decide to close the connection.</summary>
92-
public void AutoCloseConnection()
93-
{
94-
_connection.Abort(Constants.ReplySuccess, "AutoClose", ShutdownInitiator.Library, Timeout.InfiniteTimeSpan);
95-
}
96-
97-
///<summary>If m_autoClose and there are no active sessions
98-
///remaining, Close()s the connection with reason code
99-
///200.</summary>
100-
public void CheckAutoClose()
101-
{
102-
if (_autoClose)
103-
{
104-
lock (_sessionMap)
105-
{
106-
if (_sessionMap.Count == 0)
107-
{
108-
// Run this in a separate task, because
109-
// usually CheckAutoClose will be called from
110-
// HandleSessionShutdown above, which runs in
111-
// the thread of the connection. If we were to
112-
// attempt to close the connection synchronously,
113-
// we would suffer a deadlock as the connection thread
114-
// would be blocking waiting for its own mainloop
115-
// to reply to it.
116-
Task.Run((Action)AutoCloseConnection).Wait();
117-
}
118-
}
119-
}
120-
}
121-
12273
public ISession Create()
12374
{
12475
lock (_sessionMap)
@@ -162,7 +113,6 @@ public void HandleSessionShutdown(object sender, ShutdownEventArgs reason)
162113
var session = (ISession)sender;
163114
_sessionMap.Remove(session.ChannelNumber);
164115
_ints.Free(session.ChannelNumber);
165-
CheckAutoClose();
166116
}
167117
}
168118

0 commit comments

Comments
 (0)