`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>
| ... | ... |
@@ -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) |