Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal abstract class TransportDuplexSessionChannel : TransportOutputChannel,
{
private bool _isInputSessionClosed;
private bool _isOutputSessionClosed;
private bool _releasingConnection;
private Uri _localVia;
private ChannelBinding _channelBindingToken;

Expand Down Expand Up @@ -290,6 +291,11 @@ protected async Task CloseOutputSessionAsync(TimeSpan timeout)

protected override void OnAbort()
{
if (_releasingConnection)
{
// We are releasing the connection to the pool.
return;
}
ReturnConnectionIfNecessary(true, TimeSpan.Zero);
}

Expand Down Expand Up @@ -567,6 +573,9 @@ private void OnOutputSessionClosed(ref TimeoutHelper timeoutHelper)

if (releaseConnection)
{
// Call Abort() to ensure proper channel state before returning the connection to the pool.
_releasingConnection = true;
Abort();
ReturnConnectionIfNecessary(false, timeoutHelper.RemainingTime());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ private void SetupInnerChannelFaultHandler()
// NullReferenceException in this method or in the OnInnerChannelFaulted method;
// because this method accesses this.binder and OnInnerChannelFaulted accesses this.clientRuntime.
Binder.Channel.Faulted += OnInnerChannelFaulted;
Binder.Channel.Closed += OnInnerChannelClosed;
}

private void BindDuplexCallbacks()
Expand Down Expand Up @@ -1169,6 +1170,16 @@ private void OnInnerChannelFaulted(object sender, EventArgs e)
}
}

private void OnInnerChannelClosed(object sender, EventArgs e)
{
if (HasSession)
{
DispatchRuntime dispatchRuntime = ClientRuntime.DispatchRuntime;
}

Abort();
}

private void AddMessageProperties(Message message, OperationContext context)
{
if (_allowOutputBatching)
Expand Down
Loading