From d85f3696b0bd0491a5ca4196fbcb6e44f04ccdd0 Mon Sep 17 00:00:00 2001 From: braams Date: Tue, 28 May 2024 15:36:11 +0200 Subject: [PATCH] Terminate the goroutine on shutdown --- sippy/sip_transaction_manager.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sippy/sip_transaction_manager.go b/sippy/sip_transaction_manager.go index b43b922..d7a71d4 100644 --- a/sippy/sip_transaction_manager.go +++ b/sippy/sip_transaction_manager.go @@ -98,8 +98,12 @@ func NewSipTransactionManager(config sippy_conf.Config, call_map sippy_types.Cal } go func() { for { - time.Sleep(32 * time.Second) - self.rCachePurge() + select { + case <-self.shutdown_chan: + return + case <-time.After(32 * time.Second): + self.rCachePurge() + } } }() return self, nil @@ -730,7 +734,7 @@ func (self *sipTransactionManager) tserver_replace(old_tid, new_tid *sippy_heade } func (self *sipTransactionManager) Shutdown() { - self.shutdown_chan <- 1 + close(self.shutdown_chan) } func (self *sipTransactionManager) beforeResponseSent(resp sippy_types.SipResponse) {