Skip to content

Commit b21af89

Browse files
committed
Revert "* Ensure frame payload rented bytes are returned even in exception case."
This reverts commit 6243282.
1 parent 677b359 commit b21af89

File tree

1 file changed

+34
-39
lines changed

1 file changed

+34
-39
lines changed

projects/RabbitMQ.Client/client/impl/Connection.Receive.cs

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -133,56 +133,51 @@ await ProcessFrameAsync(asyncFrame, mainLoopCancellationToken)
133133
private async Task ProcessFrameAsync(InboundFrame frame, CancellationToken cancellationToken)
134134
{
135135
bool shallReturnPayload = true;
136-
try
136+
if (frame.Channel == 0)
137137
{
138-
if (frame.Channel == 0)
138+
if (frame.Type == FrameType.FrameHeartbeat)
139139
{
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-
}
140+
// Ignore it: we've already recently reset the heartbeat
159141
}
160142
else
161143
{
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-
}
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);
177156
}
178157
}
179-
finally
158+
else
180159
{
181-
if (shallReturnPayload)
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)
182166
{
183-
frame.ReturnPayload();
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);
184174
}
185175
}
176+
177+
if (shallReturnPayload)
178+
{
179+
frame.ReturnPayload();
180+
}
186181
}
187182

188183
///<remarks>

0 commit comments

Comments
 (0)