From 4b3ee31f74a8835174a1760e04d88527188ffc5c Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Tue, 5 Sep 2023 18:18:37 -0500 Subject: [PATCH] fix(server): Allow timer to be garbage collected more quickly --- internal/server/ssh.go | 1 + internal/server/telnet.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/server/ssh.go b/internal/server/ssh.go index 2217294d..b2c10d6b 100644 --- a/internal/server/ssh.go +++ b/internal/server/ssh.go @@ -122,6 +122,7 @@ func (s *SSHServer) Handler(m *movie.Movie) bubbletea.ProgramHandler { go func() { if timeout != 0 { timer := time.NewTimer(timeout) + defer timer.Stop() select { case <-timer.C: program.Send(movie.Quit()) diff --git a/internal/server/telnet.go b/internal/server/telnet.go index 13a757d7..fa75dd92 100644 --- a/internal/server/telnet.go +++ b/internal/server/telnet.go @@ -119,6 +119,7 @@ func (s *TelnetServer) Handler(ctx context.Context, conn net.Conn, m *movie.Movi go func() { if timeout != 0 { timer := time.NewTimer(timeout) + defer timer.Stop() select { case <-timer.C: program.Send(movie.Quit())