Skip to content

Commit

Permalink
Avoid non-op when the list of Hooks is empty
Browse files Browse the repository at this point in the history
There is no need to run hooks when `Config.Hooks` is just an empty map,

(dlv) p p.config.Config.Hooks
github.com/opencontainers/runc/libcontainer/configs.Hooks []

Signed-off-by: Dave Chen <dave.chen@arm.com>
  • Loading branch information
chendave committed Nov 19, 2021
1 parent eba6097 commit 1362291
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libcontainer/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func (p *initProcess) start() (retErr error) {
}
}

if p.config.Config.Hooks != nil {
if len(p.config.Config.Hooks) != 0 {
s, err := p.container.currentOCIState()
if err != nil {
return err
Expand Down Expand Up @@ -571,7 +571,7 @@ func (p *initProcess) start() (retErr error) {
return fmt.Errorf("error setting Intel RDT config for procHooks process: %w", err)
}
}
if p.config.Config.Hooks != nil {
if len(p.config.Config.Hooks) != 0 {
s, err := p.container.currentOCIState()
if err != nil {
return err
Expand Down

0 comments on commit 1362291

Please sign in to comment.