From 54fb96431e31fb6d7f0c47f2a661d1ea167599b4 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Sat, 16 Mar 2024 19:12:59 +0100 Subject: [PATCH] Remove mutex as it might block go-sendxmpp forever. --- main.go | 5 ----- stanzahandling.go | 3 --- 2 files changed, 8 deletions(-) diff --git a/main.go b/main.go index 198dd80..7a36125 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,6 @@ import ( "os/signal" "runtime" "strings" - "sync" "time" "github.com/ProtonMail/gopenpgp/v2/crypto" // MIT License @@ -33,12 +32,8 @@ type configuration struct { alias string } -var mutex sync.Mutex - func closeAndExit(client *xmpp.Client, cancel context.CancelFunc, err error) { cancel() - mutex.Lock() - defer mutex.Unlock() client.Close() if err != nil { log.Fatal(err) diff --git a/stanzahandling.go b/stanzahandling.go index 16cda64..bea6d66 100644 --- a/stanzahandling.go +++ b/stanzahandling.go @@ -52,9 +52,7 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx case <-ctx.Done(): return default: - mutex.Lock() received, err = client.Recv() - mutex.Unlock() } // Don't print errors if the program is getting shut down, // as the errors might be triggered from trying to read from @@ -64,7 +62,6 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx return default: if err != nil { - mutex.Unlock() closeAndExit(client, cancel, err) } }