Skip to content

Commit

Permalink
fixed a data race issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lni authored and volgariver6 committed Mar 21, 2023
1 parent e5eb6d7 commit d72849e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions memberlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ func (m *Memberlist) Leave(timeout time.Duration) error {

m.nodeLock.Lock()
state, ok := m.nodeMap[m.config.Name]
incarnation := state.Incarnation
name := state.Name
m.nodeLock.Unlock()
if !ok {
m.logger.Printf("[WARN] memberlist: Leave but we're not in the node map.")
Expand All @@ -669,9 +671,9 @@ func (m *Memberlist) Leave(timeout time.Duration) error {
// intentionally. When Node equals From, other nodes know for
// sure this node is gone.
d := dead{
Incarnation: state.Incarnation,
Node: state.Name,
From: state.Name,
Incarnation: incarnation,
Node: name,
From: name,
}
m.deadNode(&d)

Expand Down

0 comments on commit d72849e

Please sign in to comment.