Don't close throttle channel, explain why
This commit is contained in:
parent
e430d3f844
commit
8b518fadb2
|
@ -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:
|
||||
|
|
|
@ -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…
Reference in New Issue