Explorar o código

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 %!s(int64=7) %!d(string=hai) anos
pai
achega
bc465326fe
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      libnetwork/networkdb/delegate.go

+ 2 - 2
libnetwork/networkdb/delegate.go

@@ -21,8 +21,8 @@ func (nDB *NetworkDB) handleNodeEvent(nEvent *NodeEvent) bool {
 	// time.
 	nDB.networkClock.Witness(nEvent.LTime)
 
-	nDB.RLock()
-	defer nDB.RUnlock()
+	nDB.Lock()
+	defer nDB.Unlock()
 
 	// check if the node exists
 	n, _, _ := nDB.findNode(nEvent.NodeName)