From ff310d6bc6a0e6848be4a101daefeb3d0569ae7d Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 29 Oct 2018 12:51:56 +0100 Subject: [PATCH] detect underlying mux worker closed --- app/reverse/bridge.go | 2 +- common/mux/server.go | 4 ++++ common/mux/session.go | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/reverse/bridge.go b/app/reverse/bridge.go index 0d65a7071..99c644e4b 100644 --- a/app/reverse/bridge.go +++ b/app/reverse/bridge.go @@ -137,7 +137,7 @@ func (w *BridgeWorker) Close() error { } func (w *BridgeWorker) IsActive() bool { - return w.state == Control_ACTIVE + return w.state == Control_ACTIVE && !w.worker.Closed() } func (w *BridgeWorker) Connections() uint32 { diff --git a/common/mux/server.go b/common/mux/server.go index 68eac8f1c..979eeec7e 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -96,6 +96,10 @@ func (w *ServerWorker) ActiveConnections() uint32 { return uint32(w.sessionManager.Size()) } +func (w *ServerWorker) Closed() bool { + return w.sessionManager.Closed() +} + func (w *ServerWorker) handleStatusKeepAlive(meta *FrameMetadata, reader *buf.BufferedReader) error { if meta.Option.Has(OptionData) { return buf.Copy(NewStreamReader(reader), buf.Discard) diff --git a/common/mux/session.go b/common/mux/session.go index 53c041510..c0759f96f 100644 --- a/common/mux/session.go +++ b/common/mux/session.go @@ -22,6 +22,13 @@ func NewSessionManager() *SessionManager { } } +func (m *SessionManager) Closed() bool { + m.RLock() + defer m.RUnlock() + + return m.closed +} + func (m *SessionManager) Size() int { m.RLock() defer m.RUnlock()