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

v0.10
Martin Dosch 2 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"
"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)

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

Loading…
Cancel
Save