[MM-60307] Check if session is nil before calling UpdateLastActivityAtIfNeeded (#28254)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9900151fb6
Коммит
20ed58906a
@@ -17,11 +17,12 @@ import (
|
|||||||
func (ps *PlatformService) ReturnSessionToPool(session *model.Session) {
|
func (ps *PlatformService) ReturnSessionToPool(session *model.Session) {
|
||||||
if session != nil {
|
if session != nil {
|
||||||
session.Id = ""
|
session.Id = ""
|
||||||
// Once the session is retrieved from the pool, all existing prop fields are cleared.
|
// All existing prop fields are cleared once the session is retrieved from the pool.
|
||||||
// To avoid a race between clearing the props and accessing it, clear the props maps before returning it to the pool.
|
// To speed up that process, clear the props here to avoid doing that in the hot path.
|
||||||
|
//
|
||||||
|
// If the request handler spawns a goroutine that uses the session, it might race with this code.
|
||||||
|
// In that case, the handler should copy the session and use the copy in the goroutine.
|
||||||
clear(session.Props)
|
clear(session.Props)
|
||||||
// Also clear the team members slice to avoid a similar race condition.
|
|
||||||
clear(session.TeamMembers)
|
|
||||||
ps.sessionPool.Put(session)
|
ps.sessionPool.Put(session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,10 @@ func (ps *PlatformService) NewWebConn(cfg *WebConnConfig, suite SuiteIFace, runn
|
|||||||
// Create a goroutine to avoid blocking the creation of the websocket connection.
|
// Create a goroutine to avoid blocking the creation of the websocket connection.
|
||||||
ps.Go(func() {
|
ps.Go(func() {
|
||||||
ps.SetStatusOnline(userID, false)
|
ps.SetStatusOnline(userID, false)
|
||||||
ps.UpdateLastActivityAtIfNeeded(*wc.GetSession())
|
session := wc.GetSession()
|
||||||
|
if session != nil {
|
||||||
|
ps.UpdateLastActivityAtIfNeeded(*session)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user