Merge pull request #4683 from heyitsanthony/recipes-err-handling

contrib/recipes: fix nil dereferences on error paths
This commit is contained in:
Anthony Romano 2016-03-04 09:32:27 -08:00
commit 06f950f614
2 changed files with 6 additions and 0 deletions

View File

@ -74,6 +74,9 @@ func (b *DoubleBarrier) Enter() error {
// Leave waits for "count" processes to leave the barrier then returns
func (b *DoubleBarrier) Leave() error {
resp, err := b.client.Get(b.ctx, b.key+"/waiters", clientv3.WithPrefix())
if err != nil {
return err
}
if len(resp.Kvs) == 0 {
return nil
}

View File

@ -91,6 +91,9 @@ func (s *STM) commit() (ok bool, rr error) {
puts = append(puts, v3.OpPut(k, v))
}
txnresp, err := s.client.Txn(context.TODO()).If(cmps...).Then(puts...).Commit()
if err != nil {
return false, err
}
return txnresp.Succeeded, err
}