mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #4683 from heyitsanthony/recipes-err-handling
contrib/recipes: fix nil dereferences on error paths
This commit is contained in:
commit
06f950f614
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user