From 915b869e3fc6377be114c033763987de612c443c Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Fri, 6 Jan 2023 22:49:26 +0100 Subject: lint: add missing panic handlers in goroutines These issues were all reported by the new custom analyzer introduced in previous commit. Signed-off-by: Robin Jarry Tested-by: Bence Ferdinandy --- worker/imap/cache.go | 1 + worker/imap/connect.go | 2 ++ worker/imap/observer.go | 2 ++ 3 files changed, 5 insertions(+) (limited to 'worker/imap') diff --git a/worker/imap/cache.go b/worker/imap/cache.go index b8673ae7..352ef313 100644 --- a/worker/imap/cache.go +++ b/worker/imap/cache.go @@ -145,6 +145,7 @@ func cacheDir() (string, error) { // cleanCache removes stale entries from the selected mailbox cachedb func (w *IMAPWorker) cleanCache(path string) { + defer log.PanicHandler() start := time.Now() var scanned, removed int iter := w.cache.NewIterator(nil, nil) diff --git a/worker/imap/connect.go b/worker/imap/connect.go index d6c946db..5be916e7 100644 --- a/worker/imap/connect.go +++ b/worker/imap/connect.go @@ -111,6 +111,7 @@ func newTCPConn(addr string, timeout time.Duration) (*net.TCPConn, error) { done := make(chan tcpConn) go func() { + defer log.PanicHandler() addr, err := net.ResolveTCPAddr("tcp", addr) if err != nil { done <- tcpConn{nil, err} @@ -129,6 +130,7 @@ func newTCPConn(addr string, timeout time.Duration) (*net.TCPConn, error) { select { case <-time.After(timeout): go func() { + defer log.PanicHandler() if tcpResult := <-done; tcpResult.conn != nil { tcpResult.conn.Close() } diff --git a/worker/imap/observer.go b/worker/imap/observer.go index 2cfe8bd9..9ad311dd 100644 --- a/worker/imap/observer.go +++ b/worker/imap/observer.go @@ -76,6 +76,7 @@ func (o *observer) Start() { return } go func() { + defer log.PanicHandler() select { case <-o.client.LoggedOut(): o.log("<-logout") @@ -129,6 +130,7 @@ func (o *observer) DelayedReconnect() error { } go func() { + defer log.PanicHandler() <-time.After(wait) o.emit(reterr.Error()) }() -- cgit