Skip to content

Commit

Permalink
reduce the range of the lock
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed Sep 11, 2019
1 parent f12d472 commit ef6bbe4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ func (g *OptGroup) Set(name string, value interface{}) {

// Check whether the current group or the option is frozen.
if g.optIsFrozen(name) {
g.conf.handleError(NewOptError(g.Name(), name, ErrFrozenOpt, value))
g.lock.Unlock()
g.conf.handleError(NewOptError(g.Name(), name, ErrFrozenOpt, value))
return
}

Expand All @@ -614,13 +614,12 @@ func (g *OptGroup) Set(name string, value interface{}) {
g.conf.UpdateValue(migrate, new)
}
g.conf.noticeOptChange(g.name, name, old, new, observers)
return
case ErrNoOpt:
g.conf.handleError(NewOptError(g.Name(), name, err, value))
g.lock.Unlock()
g.conf.handleError(NewOptError(g.Name(), name, err, value))
default:
g.conf.handleError(err)
g.lock.Unlock()
g.conf.handleError(err)
}
}

Expand Down
2 changes: 2 additions & 0 deletions opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type Opt struct {
// When updating the option value, the validators will validate it.
// If there is a validator returns an error, the updating fails and
// returns the error. That's, these validators are the AND relations.
//
// Notice: they must not panic.
Validators []Validator
}

Expand Down

0 comments on commit ef6bbe4

Please sign in to comment.