mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
node: fix racy access to httpConfig.prefix
This commit is contained in:
parent
4f468ae488
commit
f545cc3587
1 changed files with 5 additions and 2 deletions
|
|
@ -62,6 +62,7 @@ type rpcEndpointConfig struct {
|
||||||
|
|
||||||
type rpcHandler struct {
|
type rpcHandler struct {
|
||||||
http.Handler
|
http.Handler
|
||||||
|
prefix string
|
||||||
server *rpc.Server
|
server *rpc.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,7 +198,7 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
// check if ws request and serve if ws enabled
|
// check if ws request and serve if ws enabled
|
||||||
ws := h.wsHandler.Load()
|
ws := h.wsHandler.Load()
|
||||||
if ws != nil && isWebsocket(r) {
|
if ws != nil && isWebsocket(r) {
|
||||||
if checkPath(r, h.wsConfig.prefix) {
|
if checkPath(r, ws.prefix) {
|
||||||
ws.ServeHTTP(w, r)
|
ws.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
@ -216,7 +217,7 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if checkPath(r, h.httpConfig.prefix) {
|
if checkPath(r, rpc.prefix) {
|
||||||
rpc.ServeHTTP(w, r)
|
rpc.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -312,6 +313,7 @@ func (h *httpServer) enableRPC(apis []rpc.API, config httpConfig) error {
|
||||||
h.httpConfig = config
|
h.httpConfig = config
|
||||||
h.httpHandler.Store(&rpcHandler{
|
h.httpHandler.Store(&rpcHandler{
|
||||||
Handler: NewHTTPHandlerStack(srv, config.CorsAllowedOrigins, config.Vhosts, config.jwtSecret),
|
Handler: NewHTTPHandlerStack(srv, config.CorsAllowedOrigins, config.Vhosts, config.jwtSecret),
|
||||||
|
prefix: config.prefix,
|
||||||
server: srv,
|
server: srv,
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -347,6 +349,7 @@ func (h *httpServer) enableWS(apis []rpc.API, config wsConfig) error {
|
||||||
h.wsConfig = config
|
h.wsConfig = config
|
||||||
h.wsHandler.Store(&rpcHandler{
|
h.wsHandler.Store(&rpcHandler{
|
||||||
Handler: NewWSHandlerStack(srv.WebsocketHandler(config.Origins), config.jwtSecret),
|
Handler: NewWSHandlerStack(srv.WebsocketHandler(config.Origins), config.jwtSecret),
|
||||||
|
prefix: config.prefix,
|
||||||
server: srv,
|
server: srv,
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue