From 4cb240981ebaf10ba3213e604ebc10b5fcf1dc16 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Mon, 4 Nov 2024 12:31:16 +0800 Subject: [PATCH] node: fix a deadlock (#17891) --- node/node.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/node/node.go b/node/node.go index fb1d9b4a99..9673bb49e0 100644 --- a/node/node.go +++ b/node/node.go @@ -569,11 +569,23 @@ func (n *Node) IPCEndpoint() string { // HTTPEndpoint retrieves the current HTTP endpoint used by the protocol stack. func (n *Node) HTTPEndpoint() string { + n.lock.Lock() + defer n.lock.Unlock() + + if n.httpListener != nil { + return n.httpListener.Addr().String() + } return n.httpEndpoint } // WSEndpoint retrieves the current WS endpoint used by the protocol stack. func (n *Node) WSEndpoint() string { + n.lock.Lock() + defer n.lock.Unlock() + + if n.wsListener != nil { + return n.wsListener.Addr().String() + } return n.wsEndpoint }