Skip to content

Commit

Permalink
fix-lint: remove select on a single case
Browse files Browse the repository at this point in the history
  • Loading branch information
F1bonacc1 committed Oct 2, 2024
1 parent b245a4b commit e68fb5f
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/app/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,18 +388,16 @@ func (p *Process) stopProcess(cancelReadinessFuncs bool) error {
p.mtxStopFn.Lock()
p.waitForStoppedCtx, p.waitForStoppedFn = context.WithTimeout(context.Background(), time.Duration(p.procConf.ShutDownParams.ShutDownTimeout)*time.Second)
p.mtxStopFn.Unlock()
select {
case <-p.waitForStoppedCtx.Done():
err = p.waitForStoppedCtx.Err()
switch {
case errors.Is(err, context.Canceled):
return nil
case errors.Is(err, context.DeadlineExceeded):
return p.command.Stop(int(syscall.SIGKILL), p.procConf.ShutDownParams.ParentOnly)
default:
log.Error().Err(err).Msgf("terminating %s with timeout %d failed", p.getName(), p.procConf.ShutDownParams.ShutDownTimeout)
return err
}
<-p.waitForStoppedCtx.Done()
err = p.waitForStoppedCtx.Err()
switch {
case errors.Is(err, context.Canceled):
return nil
case errors.Is(err, context.DeadlineExceeded):
return p.command.Stop(int(syscall.SIGKILL), p.procConf.ShutDownParams.ParentOnly)
default:
log.Error().Err(err).Msgf("terminating %s with timeout %d failed", p.getName(), p.procConf.ShutDownParams.ShutDownTimeout)
return err
}
}

Expand Down Expand Up @@ -839,13 +837,11 @@ func (p *Process) setPassword(password string) error {
}

func (p *Process) waitForPass() error {
select {
case <-p.waitForPassCtx.Done():
if !p.passProvided {
return fmt.Errorf("wrong password for elevated process %s, %s", p.getName(), p.waitForPassCtx.Err())
}
return nil
<-p.waitForPassCtx.Done()
if !p.passProvided {
return fmt.Errorf("wrong password for elevated process %s, %s", p.getName(), p.waitForPassCtx.Err())
}
return nil
}

func isWrongPasswordEntered(output string) bool {
Expand Down

0 comments on commit e68fb5f

Please sign in to comment.