MM-26575: Move app initialization inside Websocket router out of handler (#14991)
* MM-26575: Move app initialization inside Websocket router out of handler The websocket router struct is shared amongst multiple handlers. Therefore, there is a race condition while setting the app field and reading from it. We move the initialization of the app field when the router struct is initialized. And we also remove the initializations of some app fields which caused race conditions by being written from multiple goroutines. They are already being written once inside the AppInitializedOnce.Do method and it's redundant to set them again to the same value. * Add missing fields in server connector Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1f09d86f42
Коммит
d9ee26a47b
@@ -392,6 +392,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
server: s,
|
||||
handlers: make(map[string]webSocketHandler),
|
||||
}
|
||||
s.WebSocketRouter.app = fakeApp
|
||||
|
||||
if appErr := mailservice.TestConnection(s.Config()); appErr != nil {
|
||||
mlog.Error("Mail server connection test is failed: " + appErr.Message)
|
||||
|
||||
@@ -26,7 +26,6 @@ func (wr *WebSocketRouter) Handle(action string, handler webSocketHandler) {
|
||||
}
|
||||
|
||||
func (wr *WebSocketRouter) ServeWebSocket(conn *WebConn, r *model.WebSocketRequest) {
|
||||
wr.app = New(ServerConnector(wr.server))
|
||||
wr.app.InitServer()
|
||||
|
||||
if r.Action == "" {
|
||||
|
||||
Ссылка в новой задаче
Block a user