Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: uint8 overflow for the number of listeners #78

Merged
merged 1 commit into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Config struct {
// NumPollers configures number of priority queue pollers
// Should be no more than 255
// Default - num logical cores
NumPollers uint8 `mapstructure:"num_pollers"`
NumPollers int `mapstructure:"num_pollers"`

// PipelineSize is the limit of a main jobs queue which consume Items from the drivers pipeline
// Driver pipeline might be much larger than a main jobs queue
Expand Down Expand Up @@ -58,6 +58,6 @@ func (c *Config) InitDefaults() {
// NumPollers is hardcoded because it should be slightly more than the number of workers
// to properly load all workers
if c.NumPollers == 0 {
c.NumPollers = uint8(c.Pool.NumWorkers) + 2
c.NumPollers = int(c.Pool.NumWorkers) + 2
}
}
2 changes: 1 addition & 1 deletion listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

// non blocking listener
func (p *Plugin) listener() { //nolint:gocognit
for i := uint8(0); i < p.cfg.NumPollers; i++ {
for i := 0; i < p.cfg.NumPollers; i++ {
go func() {
for {
select {
Expand Down
2 changes: 1 addition & 1 deletion plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (p *Plugin) Stop(context.Context) error {
// but if not, this is not a problem at all.
// The main target is to stop the drivers
go func() {
for i := uint8(0); i < p.cfg.NumPollers+1; i++ {
for i := 0; i < p.cfg.NumPollers; i++ {
// stop jobs plugin pollers
p.stopCh <- struct{}{}
}
Expand Down