Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions node/rpcstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type httpServer struct {
timeouts rpc.HTTPTimeouts
mux http.ServeMux // registered handlers go here

mu sync.Mutex
mu sync.RWMutex
server *http.Server
listener net.Listener // non-nil when server is running

Expand Down Expand Up @@ -207,7 +207,9 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

// if http-rpc is enabled, try to serve request
h.mu.RLock()
rpc := h.httpHandler.Load().(*rpcHandler)
h.mu.RUnlock()
if rpc != nil {
// First try to route in the mux.
// Requests to a path below root are handled by the mux,
Expand All @@ -219,7 +221,11 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

if checkPath(r, h.httpConfig.prefix) {
h.mu.RLock()
prefix := h.httpConfig.prefix
h.mu.RUnlock()

if checkPath(r, prefix) {
rpc.ServeHTTP(w, r)
return
}
Expand Down