MM-17489: fixed racy tryExecutePluginCommand (#11780)

* MM-17489: fixed racy tryExecutePluginCommand

* PR feedback

* MM 7971 dockerhost -> localhost && docker -> docker-compose (#10872)

* replace dockerhost with localhost

* remove uneeded setup-max build step (no more dockerhost)

* changes as recommended by @cpanato

* make clean-docker with docker-compose

* added ports to docker-compose.yml (needed for osx).   ignore error for ldapadd (when already exists)

* add clean-old-docker to legacy.mk

* docker-compose stop instead of down for `make stop-docker`

* MM-17117: Updates einterface for FirstLoginSync. (#11737)

* update sampledata users passwords (#11769)

* update sampledata users passwords

* update makefile

* Tweak docker compose setup (#11785)

* fix stray dockerhost mention

* fix stray whitespace

* fix missing mattermost-redix cleanup in clean-old-docker

* absolute path to docker-compose, plus simpler ldap initialization

* allow ldapadd to fail on CI

* MM-16366 - Prevent attachment duplication on import (#11770)

* prevent attachment duplication

* improved tests

* corrected import into a new post

* WIP: a failed attempt to add tests

* remove debugging statements

* fix godoc

* enable plugins when testing

* rework reentrant unit tests
Этот коммит содержится в:
Lev
2019-09-10 09:28:12 -07:00
коммит произвёл Jesse Hallam
родитель 94eb3caa73
Коммит 9e6c5e8ea6
4 изменённых файлов: 133 добавлений и 13 удалений

Просмотреть файл

@@ -97,20 +97,29 @@ func (a *App) tryExecutePluginCommand(args *model.CommandArgs) (*model.Command,
trigger := parts[0][1:]
trigger = strings.ToLower(trigger)
var matched *PluginCommand
a.Srv.pluginCommandsLock.RLock()
defer a.Srv.pluginCommandsLock.RUnlock()
for _, pc := range a.Srv.pluginCommands {
if (pc.Command.TeamId == "" || pc.Command.TeamId == args.TeamId) && pc.Command.Trigger == trigger {
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
pluginHooks, err := pluginsEnvironment.HooksForPlugin(pc.PluginId)
if err != nil {
return pc.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command.error.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
}
response, appErr := pluginHooks.ExecuteCommand(a.PluginContext(), args)
return pc.Command, response, appErr
}
matched = pc
break
}
}
return nil, nil, nil
a.Srv.pluginCommandsLock.RUnlock()
if matched == nil {
return nil, nil, nil
}
pluginsEnvironment := a.GetPluginsEnvironment()
if pluginsEnvironment == nil {
return nil, nil, nil
}
pluginHooks, err := pluginsEnvironment.HooksForPlugin(matched.PluginId)
if err != nil {
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command.error.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
}
response, appErr := pluginHooks.ExecuteCommand(a.PluginContext(), args)
return matched.Command, response, appErr
}