protected void CleanUp(bool aborting, TimeSpan timeout) { // We need to be able to call Stop/Abort without acquiring ThisLock. Otherwise there's a deadlock with OnDuplicatedVia() SharedConnectionListener currentListener = Interlocked.Exchange <SharedConnectionListener>(ref this.listener, null); if (currentListener != null) { if (!aborting) { currentListener.Stop(timeout); } else { currentListener.Abort(); } } lock (ThisLock) { if (connectionDemuxer != null && demuxerCreated) { connectionDemuxer.Dispose(); } demuxerCreated = false; } }
protected void CleanUp(bool aborting, TimeSpan timeout) { lock (ThisLock) { if (listener != null) { if (!aborting) { listener.Stop(timeout); } else { listener.Abort(); } // The listener will be closed by the demuxer. listener = null; } if (connectionDemuxer != null) { connectionDemuxer.Dispose(); } demuxerCreated = false; } }