MM-26836: Remove some app fields which cause race conditions (#15019)
`(a *App) InitServer` was being called from multiple goroutines and were modifying the fields of the App struct concurrently. However, the fields were just reflecting the Server fields, and we already have public getters for those fields. Therefore, we remove those fields and just change the code to return the server field directly. Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d22dd262ee
Коммит
339c5bae76
32
app/app.go
32
app/app.go
@@ -38,16 +38,12 @@ type App struct {
|
||||
userAgent string
|
||||
acceptLanguage string
|
||||
|
||||
accountMigration einterfaces.AccountMigrationInterface
|
||||
cluster einterfaces.ClusterInterface
|
||||
compliance einterfaces.ComplianceInterface
|
||||
dataRetention einterfaces.DataRetentionInterface
|
||||
searchEngine *searchengine.Broker
|
||||
ldap einterfaces.LdapInterface
|
||||
messageExport einterfaces.MessageExportInterface
|
||||
metrics einterfaces.MetricsInterface
|
||||
notification einterfaces.NotificationInterface
|
||||
saml einterfaces.SamlInterface
|
||||
cluster einterfaces.ClusterInterface
|
||||
compliance einterfaces.ComplianceInterface
|
||||
dataRetention einterfaces.DataRetentionInterface
|
||||
searchEngine *searchengine.Broker
|
||||
messageExport einterfaces.MessageExportInterface
|
||||
metrics einterfaces.MetricsInterface
|
||||
|
||||
httpService httpservice.HTTPService
|
||||
imageProxy *imageproxy.ImageProxy
|
||||
@@ -69,10 +65,6 @@ func New(options ...AppOption) *App {
|
||||
func (a *App) InitServer() {
|
||||
a.srv.AppInitializedOnce.Do(func() {
|
||||
a.initEnterprise()
|
||||
a.accountMigration = a.srv.AccountMigration
|
||||
a.ldap = a.srv.Ldap
|
||||
a.notification = a.srv.Notification
|
||||
a.saml = a.srv.Saml
|
||||
|
||||
a.AddConfigListener(func(oldConfig *model.Config, newConfig *model.Config) {
|
||||
if *oldConfig.GuestAccountsSettings.Enable && !*newConfig.GuestAccountsSettings.Enable {
|
||||
@@ -116,10 +108,6 @@ func (a *App) InitServer() {
|
||||
}
|
||||
a.srv.RunJobs()
|
||||
})
|
||||
a.accountMigration = a.srv.AccountMigration
|
||||
a.ldap = a.srv.Ldap
|
||||
a.notification = a.srv.Notification
|
||||
a.saml = a.srv.Saml
|
||||
}
|
||||
|
||||
func (a *App) initJobs() {
|
||||
@@ -467,7 +455,7 @@ func (a *App) AcceptLanguage() string {
|
||||
return a.acceptLanguage
|
||||
}
|
||||
func (a *App) AccountMigration() einterfaces.AccountMigrationInterface {
|
||||
return a.accountMigration
|
||||
return a.srv.AccountMigration
|
||||
}
|
||||
func (a *App) Cluster() einterfaces.ClusterInterface {
|
||||
return a.cluster
|
||||
@@ -482,7 +470,7 @@ func (a *App) SearchEngine() *searchengine.Broker {
|
||||
return a.searchEngine
|
||||
}
|
||||
func (a *App) Ldap() einterfaces.LdapInterface {
|
||||
return a.ldap
|
||||
return a.srv.Ldap
|
||||
}
|
||||
func (a *App) MessageExport() einterfaces.MessageExportInterface {
|
||||
return a.messageExport
|
||||
@@ -491,10 +479,10 @@ func (a *App) Metrics() einterfaces.MetricsInterface {
|
||||
return a.metrics
|
||||
}
|
||||
func (a *App) Notification() einterfaces.NotificationInterface {
|
||||
return a.notification
|
||||
return a.srv.Notification
|
||||
}
|
||||
func (a *App) Saml() einterfaces.SamlInterface {
|
||||
return a.saml
|
||||
return a.srv.Saml
|
||||
}
|
||||
func (a *App) HTTPService() httpservice.HTTPService {
|
||||
return a.httpService
|
||||
|
||||
@@ -100,7 +100,6 @@ func ServerConnector(s *Server) AppOption {
|
||||
a.log = s.Log
|
||||
a.notificationsLog = s.NotificationsLog
|
||||
|
||||
a.accountMigration = s.AccountMigration
|
||||
a.cluster = s.Cluster
|
||||
a.compliance = s.Compliance
|
||||
a.dataRetention = s.DataRetention
|
||||
|
||||
Ссылка в новой задаче
Block a user