mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Fix nil pointer and goroutine safety in typing cache
Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
parent
55a4e6061a
commit
ba35a0a96d
5
typingserver/cache/cache.go
vendored
5
typingserver/cache/cache.go
vendored
|
|
@ -62,11 +62,12 @@ func (t *TypingCache) GetTypingUsersIfUpdatedAfter(
|
||||||
roomID string, position int64,
|
roomID string, position int64,
|
||||||
) (users []string, updated bool) {
|
) (users []string, updated bool) {
|
||||||
t.RLock()
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
|
||||||
roomData, ok := t.data[roomID]
|
roomData, ok := t.data[roomID]
|
||||||
userSet := roomData.userSet
|
|
||||||
t.RUnlock()
|
|
||||||
if ok && roomData.syncPosition > position {
|
if ok && roomData.syncPosition > position {
|
||||||
updated = true
|
updated = true
|
||||||
|
userSet := roomData.userSet
|
||||||
users = make([]string, 0, len(userSet))
|
users = make([]string, 0, len(userSet))
|
||||||
for userID := range userSet {
|
for userID := range userSet {
|
||||||
users = append(users, userID)
|
users = append(users, userID)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue