diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-03 10:53:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-03 10:53:53 -0500 |
commit | 5e69ce099f521aa49fc267c62235c003eae530ff (patch) | |
tree | c7177e4cac419082753225819f62d07c8b5671e8 /app/channel.go | |
parent | bfe7955fb0c72bb6f3e0a1e0aaca70cff27d7ddc (diff) | |
download | chat-5e69ce099f521aa49fc267c62235c003eae530ff.tar.gz chat-5e69ce099f521aa49fc267c62235c003eae530ff.tar.bz2 chat-5e69ce099f521aa49fc267c62235c003eae530ff.zip |
Goroutine wranglin (#7556)
* goroutine wranglin
* synchronize WebConn.WritePump
Diffstat (limited to 'app/channel.go')
-rw-r--r-- | app/channel.go | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/app/channel.go b/app/channel.go index 88f9cc7d7..2ab591c42 100644 --- a/app/channel.go +++ b/app/channel.go @@ -584,7 +584,9 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques if userId == userRequestorId { a.postJoinChannelMessage(user, channel) } else { - go a.PostAddToChannelMessage(userRequestor, user, channel) + a.Go(func() { + a.PostAddToChannelMessage(userRequestor, user, channel) + }) } a.UpdateChannelLastViewedAt([]string{channel.Id}, userRequestor.Id) @@ -958,7 +960,9 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError { return err } - go a.postLeaveChannelMessage(user, channel) + a.Go(func() { + a.postLeaveChannelMessage(user, channel) + }) } return nil @@ -1039,13 +1043,17 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string, message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", channel.Id, "", nil) message.Add("user_id", userIdToRemove) message.Add("remover_id", removerUserId) - go a.Publish(message) + a.Go(func() { + a.Publish(message) + }) // because the removed user no longer belongs to the channel we need to send a separate websocket event userMsg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", "", userIdToRemove, nil) userMsg.Add("channel_id", channel.Id) userMsg.Add("remover_id", removerUserId) - go a.Publish(userMsg) + a.Go(func() { + a.Publish(userMsg) + }) return nil } @@ -1064,7 +1072,9 @@ func (a *App) RemoveUserFromChannel(userIdToRemove string, removerUserId string, if userIdToRemove == removerUserId { a.postLeaveChannelMessage(user, channel) } else { - go a.PostRemoveFromChannelMessage(removerUserId, user, channel) + a.Go(func() { + a.PostRemoveFromChannelMessage(removerUserId, user, channel) + }) } return nil @@ -1113,7 +1123,9 @@ func (a *App) UpdateChannelLastViewedAt(channelIds []string, userId string) *mod for _, channelId := range channelIds { message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userId, nil) message.Add("channel_id", channelId) - go a.Publish(message) + a.Go(func() { + a.Publish(message) + }) } } @@ -1182,7 +1194,9 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotif if *utils.Cfg.ServiceSettings.EnableChannelViewedMessages && model.IsValidId(view.ChannelId) { message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", userId, nil) message.Add("channel_id", view.ChannelId) - go a.Publish(message) + a.Go(func() { + a.Publish(message) + }) } return times, nil |