@ -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:
go func() {
received, err = client.Recv()
r <- received
}()
select {
mutex.Unlock()
case <-r:
// Don't print errors if the program is getting shut down,