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,