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 Nov 1, 2022
1 parent e6ff9b2 commit bb7bce1
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 @@ -654,6 +654,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 @@ -665,9 +667,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 bb7bce1

Please sign in to comment.