diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-29 08:19:33 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-29 08:19:33 +0300 |
commit | f052d633ac722371271c4d621fa3046c4201956f (patch) | |
tree | 3995a648d542cb9ed69a37f58636e4964cf373f9 /xmpp/gateway/gateway.go | |
parent | 540c6cd546ccadbb2c32e435d1fdcb5af24a1360 (diff) |
Fix concurrent map writes in presence queue
Diffstat (limited to 'xmpp/gateway/gateway.go')
-rw-r--r-- | xmpp/gateway/gateway.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go index a4f3aca..779c6fe 100644 --- a/xmpp/gateway/gateway.go +++ b/xmpp/gateway/gateway.go @@ -3,6 +3,7 @@ package gateway import ( "encoding/xml" "strings" + "sync" "dev.narayana.im/narayana/telegabber/xmpp/extensions" @@ -14,6 +15,7 @@ import ( // Queue stores presences to send later var Queue = make(map[string]*stanza.Presence) +var QueueLock = sync.Mutex{} // Jid stores the component's JID object var Jid *stanza.Jid @@ -178,7 +180,9 @@ func SendPresence(component *xmpp.Component, to string, args ...args.V) error { return err } } else { + QueueLock.Lock() Queue[presence.From+presence.To] = &presence + QueueLock.Unlock() } return nil |