Remove mutex as it might block go-sendxmpp forever.

v0.9
Martin Dosch 3 months ago
parent 5f6eba4b44
commit 54fb96431e
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

@ -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)

@ -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)
}
}

Loading…
Cancel
Save