From f072865b1e0a6fd7ac5d643b28ceb73f8732f638 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Mon, 26 Feb 2024 17:26:10 +0000 Subject: [PATCH] fix: Fix receiver pool not cleaning up connections in some instances and preventing shutdown, and add additional logs --- lc-lib/receiver/pool.go | 1 + lc-lib/transports/tcp/receivertcp.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lc-lib/receiver/pool.go b/lc-lib/receiver/pool.go index 2f9f6586..f9526928 100644 --- a/lc-lib/receiver/pool.go +++ b/lc-lib/receiver/pool.go @@ -239,6 +239,7 @@ ReceiverLoop: if shutdownChan == nil && len(r.receivers) == 0 && len(r.connectionStatus) == 0 { break ReceiverLoop } + log.Info("Receiver pool waiting on %d connections to close", len(r.connectionStatus)) } case *transports.PingEvent: // Immediately send a pong back - ignore failure - remote will time itself out diff --git a/lc-lib/transports/tcp/receivertcp.go b/lc-lib/transports/tcp/receivertcp.go index 4b876061..3534a2be 100644 --- a/lc-lib/transports/tcp/receivertcp.go +++ b/lc-lib/transports/tcp/receivertcp.go @@ -243,7 +243,7 @@ func (t *receiverTCP) connectionRoutine(socket net.Conn, conn *connection) { didStart := false if err := conn.run(func() { - conn.sendEvent(transports.NewConnectEvent(conn.ctx, socket.RemoteAddr().String(), conn.socket.Desc())) + t.eventChan <- transports.NewConnectEvent(conn.ctx, socket.RemoteAddr().String(), conn.socket.Desc()) didStart = true }); err != nil { if err == ErrHardCloseRequested { @@ -256,7 +256,7 @@ func (t *receiverTCP) connectionRoutine(socket net.Conn, conn *connection) { } if didStart { - conn.sendEvent(transports.NewDisconnectEvent(conn.ctx, socket.RemoteAddr().String(), conn.socket.Desc())) + t.eventChan <- transports.NewDisconnectEvent(conn.ctx, socket.RemoteAddr().String(), conn.socket.Desc()) } t.connMutex.Lock()