GPCM: Fix recursive mutex lock from last commit

This commit is contained in:
mkwcat 2024-03-12 05:24:13 -04:00
parent e854eb0d6b
commit 820ed8a6ac
No known key found for this signature in database
GPG Key ID: 7A505679CE9E7AA9
2 changed files with 7 additions and 5 deletions

View File

@ -222,7 +222,7 @@ func (g *GameSpySession) setStatus(command common.GameSpyCommand) {
g.Status = statusMsg
if !g.StatusSet && g.User.OpenHost {
g.openHostEnabled(false)
g.openHostEnabled(false, false)
}
g.StatusSet = true
@ -318,9 +318,11 @@ func (g *GameSpySession) sendLogoutStatus() {
}
}
func (g *GameSpySession) openHostEnabled(sendStatus bool) {
mutex.Lock()
defer mutex.Unlock()
func (g *GameSpySession) openHostEnabled(sendStatus bool, lock bool) {
if lock {
mutex.Lock()
defer mutex.Unlock()
}
for _, session := range sessions {
if session.LoggedIn && session.isFriendAdded(g.User.ProfileId) && !session.isFriendAuthorized(g.User.ProfileId) {

View File

@ -85,7 +85,7 @@ func (g *GameSpySession) updateProfile(command common.GameSpyCommand) {
if openHost, ok := command.OtherValues["wwfc_openhost"]; ok {
enabled := openHost != "0"
if !g.User.OpenHost && enabled {
g.openHostEnabled(true)
g.openHostEnabled(true, true)
} else if g.User.OpenHost && !enabled {
g.openHostDisabled()
}