[MM-29295] Fix data race in app.CreatePost() (#15880)
* Fix data race * Better naming Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9cb704d537
Коммит
165c4d2dd1
@@ -320,11 +320,13 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
|
|||||||
// might be duplicating requests.
|
// might be duplicating requests.
|
||||||
a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, rpost.Id, PENDING_POST_IDS_CACHE_TTL)
|
a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, rpost.Id, PENDING_POST_IDS_CACHE_TTL)
|
||||||
|
|
||||||
|
// We make a copy of the post for the plugin hook to avoid a race condition.
|
||||||
|
rPostCopy := rpost.Clone()
|
||||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||||
a.Srv().Go(func() {
|
a.Srv().Go(func() {
|
||||||
pluginContext := a.PluginContext()
|
pluginContext := a.PluginContext()
|
||||||
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
pluginsEnvironment.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
|
||||||
hooks.MessageHasBeenPosted(pluginContext, rpost)
|
hooks.MessageHasBeenPosted(pluginContext, rPostCopy)
|
||||||
return true
|
return true
|
||||||
}, plugin.MessageHasBeenPostedId)
|
}, plugin.MessageHasBeenPostedId)
|
||||||
})
|
})
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user