Browse code

networkdb: Use write lock in handleNodeEvent

`handleNodeEvent` is calling `changeNodeState` which writes to various
maps on the ndb object.
Using a write lock prevents a panic on concurrent read/write access on
these maps.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2018/04/12 10:28:29
Showing 1 changed files
... ...
@@ -21,8 +21,8 @@ func (nDB *NetworkDB) handleNodeEvent(nEvent *NodeEvent) bool {
21 21
 	// time.
22 22
 	nDB.networkClock.Witness(nEvent.LTime)
23 23
 
24
-	nDB.RLock()
25
-	defer nDB.RUnlock()
24
+	nDB.Lock()
25
+	defer nDB.Unlock()
26 26
 
27 27
 	// check if the node exists
28 28
 	n, _, _ := nDB.findNode(nEvent.NodeName)