Skip to content

Commit

Permalink
fixed roster module race cond
Browse files Browse the repository at this point in the history
  • Loading branch information
ortuman committed Apr 7, 2019
1 parent 8a0afd8 commit f96db58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions module/roster/roster.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"strconv"
"sync"

"github.com/ortuman/jackal/model"

"github.com/ortuman/jackal/log"
"github.com/ortuman/jackal/model/rostermodel"
"github.com/ortuman/jackal/router"
Expand Down Expand Up @@ -663,8 +665,11 @@ func (x *Roster) broadcastPresence(presence *xmpp.Presence) error {
if usr, err := storage.FetchUser(fromJID.Node()); err != nil {
return err
} else if usr != nil {
usr.LastPresence = presence
return storage.InsertOrUpdateUser(usr)
return storage.InsertOrUpdateUser(&model.User{
Username: usr.Username,
Password: usr.Password,
LastPresence: presence,
})
}
return nil
}
Expand Down

0 comments on commit f96db58

Please sign in to comment.