@@ -133,51 +133,56 @@ await ProcessFrameAsync(asyncFrame, mainLoopCancellationToken)
133
133
private async Task ProcessFrameAsync ( InboundFrame frame , CancellationToken cancellationToken )
134
134
{
135
135
bool shallReturnPayload = true ;
136
- if ( frame . Channel == 0 )
136
+ try
137
137
{
138
- if ( frame . Type == FrameType . FrameHeartbeat )
138
+ if ( frame . Channel == 0 )
139
139
{
140
- // Ignore it: we've already recently reset the heartbeat
140
+ if ( frame . Type == FrameType . FrameHeartbeat )
141
+ {
142
+ // Ignore it: we've already recently reset the heartbeat
143
+ }
144
+ else
145
+ {
146
+ // In theory, we could get non-connection.close-ok
147
+ // frames here while we're quiescing (m_closeReason !=
148
+ // null). In practice, there's a limited number of
149
+ // things the server can ask of us on channel 0 -
150
+ // essentially, just connection.close. That, combined
151
+ // with the restrictions on pipelining, mean that
152
+ // we're OK here to handle channel 0 traffic in a
153
+ // quiescing situation, even though technically we
154
+ // should be ignoring everything except
155
+ // connection.close-ok.
156
+ shallReturnPayload = await _session0 . HandleFrameAsync ( frame , cancellationToken )
157
+ . ConfigureAwait ( false ) ;
158
+ }
141
159
}
142
160
else
143
161
{
144
- // In theory, we could get non-connection.close-ok
145
- // frames here while we're quiescing (m_closeReason !=
146
- // null). In practice, there's a limited number of
147
- // things the server can ask of us on channel 0 -
148
- // essentially, just connection.close. That, combined
149
- // with the restrictions on pipelining, mean that
150
- // we're OK here to handle channel 0 traffic in a
151
- // quiescing situation, even though technically we
152
- // should be ignoring everything except
153
- // connection.close-ok.
154
- shallReturnPayload = await _session0 . HandleFrameAsync ( frame , cancellationToken )
155
- . ConfigureAwait ( false ) ;
162
+ // If we're still m_running, but have a m_closeReason,
163
+ // then we must be quiescing, which means any inbound
164
+ // frames for non-zero channels (and any inbound
165
+ // commands on channel zero that aren't
166
+ // Connection.CloseOk) must be discarded.
167
+ if ( _closeReason is null )
168
+ {
169
+ // No close reason, not quiescing the
170
+ // connection. Handle the frame. (Of course, the
171
+ // Session itself may be quiescing this particular
172
+ // channel, but that's none of our concern.)
173
+ ISession session = _sessionManager . Lookup ( frame . Channel ) ;
174
+ shallReturnPayload = await session . HandleFrameAsync ( frame , cancellationToken )
175
+ . ConfigureAwait ( false ) ;
176
+ }
156
177
}
157
178
}
158
- else
179
+ finally
159
180
{
160
- // If we're still m_running, but have a m_closeReason,
161
- // then we must be quiescing, which means any inbound
162
- // frames for non-zero channels (and any inbound
163
- // commands on channel zero that aren't
164
- // Connection.CloseOk) must be discarded.
165
- if ( _closeReason is null )
181
+ if ( shallReturnPayload )
166
182
{
167
- // No close reason, not quiescing the
168
- // connection. Handle the frame. (Of course, the
169
- // Session itself may be quiescing this particular
170
- // channel, but that's none of our concern.)
171
- ISession session = _sessionManager . Lookup ( frame . Channel ) ;
172
- shallReturnPayload = await session . HandleFrameAsync ( frame , cancellationToken )
173
- . ConfigureAwait ( false ) ;
183
+ frame . ReturnPayload ( ) ;
174
184
}
175
185
}
176
-
177
- if ( shallReturnPayload )
178
- {
179
- frame . ReturnPayload ( ) ;
180
- }
181
186
}
182
187
183
188
///<remarks>
0 commit comments