MCPcopy
hub / github.com/tinode/chat / EvictUser

Method EvictUser

server/sessionstore.go:223–242  ·  view source on GitHub ↗

EvictUser terminates all sessions of a given user.

(uid types.Uid, skipSid string)

Source from the content-addressed store, hash-verified

221
222// EvictUser terminates all sessions of a given user.
223func (ss *SessionStore) EvictUser(uid types.Uid, skipSid string) {
224 ss.lock.Lock()
225 defer ss.lock.Unlock()
226
227 // FIXME: this probably needs to be optimized. This may take very long time if the node hosts 100000 sessions.
228 evicted := NoErrEvicted("", "", types.TimeNow())
229 evicted.AsUser = uid.UserId()
230 for _, s := range ss.sessCache {
231 if s.uid == uid && !s.isMultiplex() && s.sid != skipSid {
232 _, data := s.serialize(evicted)
233 s.stopSession(data)
234 delete(ss.sessCache, s.sid)
235 if s.proto == LPOLL {
236 ss.lru.Remove(s.lpTracker)
237 }
238 }
239 }
240
241 statsSet("LiveSessions", int64(len(ss.sessCache)))
242}
243
244// NodeRestarted removes stale sessions from a restarted cluster node.
245// - nodeName is the name of affected node

Callers 3

changeUserStateFunction · 0.80
replyDelUserFunction · 0.80
UserCacheUpdateMethod · 0.80

Calls 10

TimeNowFunction · 0.92
NoErrEvictedFunction · 0.85
statsSetFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
UserIdMethod · 0.80
isMultiplexMethod · 0.80
serializeMethod · 0.80
stopSessionMethod · 0.80
RemoveMethod · 0.65

Tested by

no test coverage detected