Skip to content

Commit d309982

Browse files
author
Emile Joubert
committed
Merge bug24464 into default
2 parents 140f562 + 8e407c4 commit d309982

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

projects/client/RabbitMQ.Client/src/client/impl/ConnectionBase.cs

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -425,38 +425,42 @@ public void Abort(ushort reasonCode, string reasonText,
425425
public void Close(ShutdownEventArgs reason, bool abort, int timeout)
426426
{
427427
if (!SetCloseReason(reason))
428-
if (abort)
429-
{
430-
if (!m_appContinuation.WaitOne(BlockingCell.validatedTimeout(timeout), true))
431-
m_frameHandler.Close();
432-
return;
433-
} else {
434-
throw new AlreadyClosedException(m_closeReason);
435-
}
436-
437-
OnShutdown();
438-
m_session0.SetSessionClosing(false);
439-
440-
try
441428
{
442-
// Try to send connection.close
443-
// Wait for CloseOk in the MainLoop
444-
m_session0.Transmit(ConnectionCloseWrapper(reason.ReplyCode,
445-
reason.ReplyText));
429+
if (!abort)
430+
throw new AlreadyClosedException(m_closeReason);
446431
}
447-
catch (IOException ioe) {
448-
if (m_model0.CloseReason == null)
432+
else
433+
{
434+
OnShutdown();
435+
m_session0.SetSessionClosing(false);
436+
437+
try
438+
{
439+
// Try to send connection.close
440+
// Wait for CloseOk in the MainLoop
441+
m_session0.Transmit(ConnectionCloseWrapper(reason.ReplyCode,
442+
reason.ReplyText));
443+
}
444+
catch (AlreadyClosedException ace)
449445
{
450446
if (!abort)
451-
throw ioe;
452-
else
453-
LogCloseError("Couldn't close connection cleanly. "
454-
+ "Socket closed unexpectedly", ioe);
447+
throw ace;
448+
}
449+
catch (IOException ioe)
450+
{
451+
if (m_model0.CloseReason == null)
452+
{
453+
if (!abort)
454+
throw ioe;
455+
else
456+
LogCloseError("Couldn't close connection cleanly. "
457+
+ "Socket closed unexpectedly", ioe);
458+
}
459+
}
460+
finally
461+
{
462+
TerminateMainloop();
455463
}
456-
}
457-
finally
458-
{
459-
TerminateMainloop();
460464
}
461465
if (!m_appContinuation.WaitOne(BlockingCell.validatedTimeout(timeout),true))
462466
m_frameHandler.Close();

0 commit comments

Comments
 (0)