MM-12974: guard app plugins with mutex (#9818)

* guard app plugins with mutex

Shutting down the app could race with a goroutine that uses the plugins environment, since we shut down the plugins first before cleaning up goroutines.

* fix go vet issues
Этот коммит содержится в:
Jesse Hallam
2018-11-20 08:52:51 -05:00
коммит произвёл Joram Wilander
родитель 0a73690537
Коммит c46d8ec892
15 изменённых файлов: 178 добавлений и 131 удалений

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

@@ -460,10 +460,10 @@ func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamId string, ra
info.ThumbnailPath = pathPrefix + nameWithoutExtension + "_thumb.jpg"
}
if a.PluginsReady() {
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
var rejectionError *model.AppError
pluginContext := &plugin.Context{}
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
var newBytes bytes.Buffer
replacementInfo, rejectionReason := hooks.FileWillBeUploaded(pluginContext, info, bytes.NewReader(data), &newBytes)
if rejectionReason != "" {