mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fix racy unit tests by protecting service ref with a mutex (#26183)
This commit is contained in:
parent
2116bf5498
commit
4c8a134659
@ -98,7 +98,9 @@ type PlatformService struct {
|
|||||||
goroutineBuffered chan struct{}
|
goroutineBuffered chan struct{}
|
||||||
|
|
||||||
additionalClusterHandlers map[model.ClusterEvent]einterfaces.ClusterMessageHandler
|
additionalClusterHandlers map[model.ClusterEvent]einterfaces.ClusterMessageHandler
|
||||||
sharedChannelService SharedChannelServiceIFace
|
|
||||||
|
shareChannelServiceMux sync.RWMutex
|
||||||
|
sharedChannelService SharedChannelServiceIFace
|
||||||
|
|
||||||
pluginEnv HookRunner
|
pluginEnv HookRunner
|
||||||
}
|
}
|
||||||
@ -471,9 +473,17 @@ func (ps *PlatformService) SetSqlStore(s *sqlstore.SqlStore) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ps *PlatformService) SetSharedChannelService(s SharedChannelServiceIFace) {
|
func (ps *PlatformService) SetSharedChannelService(s SharedChannelServiceIFace) {
|
||||||
|
ps.shareChannelServiceMux.Lock()
|
||||||
|
defer ps.shareChannelServiceMux.Unlock()
|
||||||
ps.sharedChannelService = s
|
ps.sharedChannelService = s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ps *PlatformService) GetSharedChannelService() SharedChannelServiceIFace {
|
||||||
|
ps.shareChannelServiceMux.RLock()
|
||||||
|
defer ps.shareChannelServiceMux.RUnlock()
|
||||||
|
return ps.sharedChannelService
|
||||||
|
}
|
||||||
|
|
||||||
func (ps *PlatformService) SetPluginsEnvironment(runner HookRunner) {
|
func (ps *PlatformService) SetPluginsEnvironment(runner HookRunner) {
|
||||||
ps.pluginEnv = runner
|
ps.pluginEnv = runner
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ var sharedChannelEventsForInvitation = []model.WebsocketEventType{
|
|||||||
// Only on the leader node it will notify the sync service to perform necessary updates to the remote for the given
|
// Only on the leader node it will notify the sync service to perform necessary updates to the remote for the given
|
||||||
// shared channel.
|
// shared channel.
|
||||||
func (ps *PlatformService) SharedChannelSyncHandler(event *model.WebSocketEvent) {
|
func (ps *PlatformService) SharedChannelSyncHandler(event *model.WebSocketEvent) {
|
||||||
syncService := ps.sharedChannelService
|
syncService := ps.GetSharedChannelService()
|
||||||
if syncService == nil {
|
if syncService == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user