38
38
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
39
39
//---------------------------------------------------------------------------
40
40
41
- using System ;
42
41
using System . Collections . Generic ;
43
- using System . Threading ;
44
- using System . Threading . Tasks ;
45
-
46
42
using RabbitMQ . Client . Exceptions ;
47
- using RabbitMQ . Client . Framing ;
48
43
using RabbitMQ . Client . Framing . Impl ;
49
44
using RabbitMQ . Util ;
50
45
@@ -56,7 +51,6 @@ class SessionManager
56
51
private readonly IntAllocator _ints ;
57
52
private readonly Connection _connection ;
58
53
private readonly Dictionary < int , ISession > _sessionMap = new Dictionary < int , ISession > ( ) ;
59
- private bool _autoClose = false ;
60
54
61
55
public SessionManager ( Connection connection , ushort channelMax )
62
56
{
@@ -65,17 +59,6 @@ public SessionManager(Connection connection, ushort channelMax)
65
59
_ints = new IntAllocator ( 1 , ChannelMax ) ;
66
60
}
67
61
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
-
79
62
public int Count
80
63
{
81
64
get
@@ -87,38 +70,6 @@ public int Count
87
70
}
88
71
}
89
72
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
-
122
73
public ISession Create ( )
123
74
{
124
75
lock ( _sessionMap )
@@ -162,7 +113,6 @@ public void HandleSessionShutdown(object sender, ShutdownEventArgs reason)
162
113
var session = ( ISession ) sender ;
163
114
_sessionMap . Remove ( session . ChannelNumber ) ;
164
115
_ints . Free ( session . ChannelNumber ) ;
165
- CheckAutoClose ( ) ;
166
116
}
167
117
}
168
118
0 commit comments