Fix access race in proxy scheduler

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2016-08-26 17:40:21 -07:00
parent 798b7331ca
commit dabdc5e52b

View file

@ -134,11 +134,12 @@ func (ttles *TTLExpirationScheduler) Start() error {
for { for {
select { select {
case <-ttles.saveTimer.C: case <-ttles.saveTimer.C:
ttles.Lock()
if !ttles.indexDirty { if !ttles.indexDirty {
ttles.Unlock()
continue continue
} }
ttles.Lock()
err := ttles.writeState() err := ttles.writeState()
if err != nil { if err != nil {
context.GetLogger(ttles.ctx).Errorf("Error writing scheduler state: %s", err) context.GetLogger(ttles.ctx).Errorf("Error writing scheduler state: %s", err)