Browse Source

Don't close throttle channel, explain why

pull/1842/head
Ethan Frey 7 years ago
parent
commit
8b518fadb2
2 changed files with 4 additions and 1 deletions
  1. +1
    -1
      common/throttle_timer.go
  2. +3
    -0
      common/throttle_timer_test.go

+ 1
- 1
common/throttle_timer.go View File

@ -52,8 +52,8 @@ func (t *ThrottleTimer) run() {
select {
case cmd := <-t.input:
// stop goroutine if the input says so
// don't close channels, as closed channels mess up select reads
if t.processInput(cmd) {
close(t.Ch)
return
}
case <-t.timer.C:


+ 3
- 0
common/throttle_timer_test.go View File

@ -31,6 +31,9 @@ func (c *thCounter) Count() int {
// Read should run in a go-routine and
// updates count by one every time a packet comes in
func (c *thCounter) Read() {
// note, since this channel never closes, this will never end
// if thCounter was used in anything beyond trivial test cases.
// it would have to be smarter.
for range c.input {
c.Increment()
}


Loading…
Cancel
Save