Skip to content

Commit

Permalink
clientv3: Eliminated race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
visheshnp committed Aug 3, 2017
1 parent d649299 commit 44d9376
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions clientv3/leasing/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func (lc *leaseCache) Get(ctx context.Context, op v3.Op) (*v3.GetResponse, bool)
if isBadOp(op) {
return nil, false
}

key := string(op.KeyBytes())
li, wc := lc.notify(key)
if li == nil {
Expand All @@ -210,11 +209,11 @@ func (lc *leaseCache) Get(ctx context.Context, op v3.Op) (*v3.GetResponse, bool)
case <-ctx.Done():
return nil, true
}

lc.mu.RLock()
lk := *li
ret := lk.get(op)
lc.mu.RUnlock()
return lk.get(op), true
return ret, true
}

func (lk *leaseKey) get(op v3.Op) *v3.GetResponse {
Expand Down

0 comments on commit 44d9376

Please sign in to comment.