From dbed11323da8519b7af0e495b5da24eeee5b0962 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Tue, 2 Apr 2024 13:44:59 +0200 Subject: [PATCH] Remove mutex as the locking is now done in the library. --- main.go | 4 ---- stanzahandling.go | 3 --- 2 files changed, 7 deletions(-) diff --git a/main.go b/main.go index 73f26c9..e26a142 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,6 @@ import ( osUser "os/user" "runtime" "strings" - "sync" "time" "github.com/ProtonMail/gopenpgp/v2/crypto" // MIT License @@ -34,11 +33,8 @@ type configuration struct { alias string } -var mutex sync.Mutex - func closeAndExit(client *xmpp.Client, cancel context.CancelFunc, err error) { cancel() - mutex.Lock() client.Close() if err != nil { log.Fatal(err) diff --git a/stanzahandling.go b/stanzahandling.go index b451446..386724c 100644 --- a/stanzahandling.go +++ b/stanzahandling.go @@ -53,17 +53,14 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx case <-ctx.Done(): return default: - mutex.Lock() go func() { received, err = client.Recv() r <- received }() select { case <-ctx.Done(): - mutex.Unlock() return case <-r: - mutex.Unlock() } } // Don't print errors if the program is getting shut down,