Skip to content

Commit

Permalink
user abort not an error
Browse files Browse the repository at this point in the history
  • Loading branch information
wiggin77 committed Jun 9, 2022
1 parent d66017d commit 478ae8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ func main() {
return
}

done := make(chan struct{})
abort := make(chan struct{})
workersExited := make(chan struct{})

setUpInterruptHandler(func() {
close(done)
close(abort)

// give the workers a chance to shut down gracefully (some may not, that's ok).
select {
Expand All @@ -127,7 +127,7 @@ func main() {
ri := &runInfo{
cfg: cfg,
logger: logger,
done: done,
abort: abort,
admin: admin,
quiet: quiet,
}
Expand Down
8 changes: 4 additions & 4 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
type runInfo struct {
cfg *Config
logger logr.Logger
done chan struct{}
abort chan struct{}
admin *AdminClient
quiet bool
blockCount int64
Expand Down Expand Up @@ -126,8 +126,8 @@ func runUser(username string, ri *runInfo) (stats, error) {
ri.IncBlockCount(len(content) + 1)

select {
case <-ri.done:
return stats, fmt.Errorf("aborting user %s", user.Username)
case <-ri.abort:
return stats, nil
case <-time.After(time.Millisecond * ri.cfg.CardDelay):
default:
}
Expand All @@ -143,7 +143,7 @@ func runUser(username string, ri *runInfo) (stats, error) {

if ri.cfg.BoardDelay != 0 {
select {
case <-ri.done:
case <-ri.abort:
return stats, fmt.Errorf("aborting user %s", user.Username)
case <-time.After(time.Millisecond * ri.cfg.BoardDelay):
}
Expand Down

0 comments on commit 478ae8f

Please sign in to comment.