Remove mutex as the locking is now done in the library.

v0.10
Martin Dosch 3 months ago
parent c13a0c7016
commit dbed11323d
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

@ -18,7 +18,6 @@ import (
osUser "os/user" osUser "os/user"
"runtime" "runtime"
"strings" "strings"
"sync"
"time" "time"
"github.com/ProtonMail/gopenpgp/v2/crypto" // MIT License "github.com/ProtonMail/gopenpgp/v2/crypto" // MIT License
@ -34,11 +33,8 @@ type configuration struct {
alias string alias string
} }
var mutex sync.Mutex
func closeAndExit(client *xmpp.Client, cancel context.CancelFunc, err error) { func closeAndExit(client *xmpp.Client, cancel context.CancelFunc, err error) {
cancel() cancel()
mutex.Lock()
client.Close() client.Close()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

@ -53,17 +53,14 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx
case <-ctx.Done(): case <-ctx.Done():
return return
default: default:
mutex.Lock()
go func() { go func() {
received, err = client.Recv() received, err = client.Recv()
r <- received r <- received
}() }()
select { select {
case <-ctx.Done(): case <-ctx.Done():
mutex.Unlock()
return return
case <-r: case <-r:
mutex.Unlock()
} }
} }
// Don't print errors if the program is getting shut down, // Don't print errors if the program is getting shut down,

Loading…
Cancel
Save