mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
[FIXED] LeafNode urls may be missing in INFO sent to LN connections
When a cluster of servers are having routes to each other, there is a chance that the list of leafnode URLs maintained on each server is not complete. This would result in LN servers connecting to this cluster to not get the full list of possible URLs the server could reconnect to. Also fixed a DATA RACE that appeared when running the updated TestLeafNodeInfoURLs test. Fixed the race and added specific test that easily demonstrated the race: TestLeafNodeNoRaceGeneratingNonce Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -507,9 +507,14 @@ func (s *Server) createLeafNode(conn net.Conn, remote *leafNodeCfg) *client {
|
||||
c.leaf.remote = remote
|
||||
}
|
||||
|
||||
var nonce [nonceLen]byte
|
||||
|
||||
// Grab server variables
|
||||
s.mu.Lock()
|
||||
info := s.copyLeafNodeInfo()
|
||||
if !solicited {
|
||||
s.generateNonce(nonce[:])
|
||||
}
|
||||
s.mu.Unlock()
|
||||
|
||||
// Grab lock
|
||||
@@ -606,7 +611,7 @@ func (s *Server) createLeafNode(conn net.Conn, remote *leafNodeCfg) *client {
|
||||
// Send our info to the other side.
|
||||
// Remember the nonce we sent here for signatures, etc.
|
||||
c.nonce = make([]byte, nonceLen)
|
||||
s.generateNonce(c.nonce)
|
||||
copy(c.nonce, nonce[:])
|
||||
info.Nonce = string(c.nonce)
|
||||
info.CID = c.cid
|
||||
b, _ := json.Marshal(info)
|
||||
|
||||
Reference in New Issue
Block a user