Fix SetTopic mutex infinity lock

This commit is contained in:
nxshock 2019-08-08 20:02:46 +05:00
parent f8c6a259e2
commit 4fc26f127e

View File

@ -114,14 +114,16 @@ func (user *User) SetTopic(room internal.Room, topic string) models.ApiError {
memRoom := room.(*Room) memRoom := room.(*Room)
memRoom.mutex.Lock() memRoom.mutex.Lock()
defer memRoom.mutex.Unlock()
if memRoom.creator.ID() != user.ID() { // TODO: currently only creator can change topic if memRoom.creator.ID() != user.ID() { // TODO: currently only creator can change topic
memRoom.mutex.Unlock()
return models.NewError(models.M_FORBIDDEN, "") return models.NewError(models.M_FORBIDDEN, "")
} }
memRoom.topic = topic memRoom.topic = topic
memRoom.mutex.Unlock()
rEvent := &RoomEvent{ rEvent := &RoomEvent{
Type: rooms.Topic, Type: rooms.Topic,
Sender: user, Sender: user,