serf: monkey patch data race in github.com/hashicorp/serf
https://github.com/hashicorp/serf/pull/476 This should be replaced when the patch is merged upstream and the library is upgraded.
This commit is contained in:
parent
0ed76615d3
commit
4322b7217c
|
@ -251,7 +251,8 @@ func (d *delegate) MergeRemoteState(buf []byte, isJoin bool) {
|
|||
// If we are doing a join, and eventJoinIgnore is set
|
||||
// then we set the eventMinTime to the EventLTime. This
|
||||
// prevents any of the incoming events from being processed
|
||||
if isJoin && d.serf.eventJoinIgnore {
|
||||
eventJoinIgnore := d.serf.eventJoinIgnore.Load().(bool)
|
||||
if isJoin && eventJoinIgnore {
|
||||
d.serf.eventLock.Lock()
|
||||
if pp.EventLTime > d.serf.eventMinTime {
|
||||
d.serf.eventMinTime = pp.EventLTime
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
|
@ -74,7 +75,7 @@ type Serf struct {
|
|||
|
||||
eventBroadcasts *memberlist.TransmitLimitedQueue
|
||||
eventBuffer []*userEvents
|
||||
eventJoinIgnore bool
|
||||
eventJoinIgnore atomic.Value
|
||||
eventMinTime LamportTime
|
||||
eventLock sync.RWMutex
|
||||
|
||||
|
@ -258,6 +259,7 @@ func Create(conf *Config) (*Serf, error) {
|
|||
shutdownCh: make(chan struct{}),
|
||||
state: SerfAlive,
|
||||
}
|
||||
serf.eventJoinIgnore.Store(false)
|
||||
|
||||
// Check that the meta data length is okay
|
||||
if len(serf.encodeTags(conf.Tags)) > memberlist.MetaMaxSize {
|
||||
|
@ -593,9 +595,9 @@ func (s *Serf) Join(existing []string, ignoreOld bool) (int, error) {
|
|||
// Ignore any events from a potential join. This is safe since we hold
|
||||
// the joinLock and nobody else can be doing a Join
|
||||
if ignoreOld {
|
||||
s.eventJoinIgnore = true
|
||||
s.eventJoinIgnore.Store(true)
|
||||
defer func() {
|
||||
s.eventJoinIgnore = false
|
||||
s.eventJoinIgnore.Store(false)
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue