mirror of
https://github.com/bettercap/bettercap
synced 2025-08-13 02:06:57 -07:00
fix: fixed a bug which prevented the buffered channel from beign cleared (fixes #198)
This commit is contained in:
parent
3e8b12f08b
commit
1f10e788ca
1 changed files with 8 additions and 1 deletions
|
@ -57,7 +57,7 @@ func NewEventPool(debug bool, silent bool) *EventPool {
|
|||
func (p *EventPool) Listen() <-chan Event {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
l := make(chan Event, 255)
|
||||
l := make(chan Event)
|
||||
p.listeners = append(p.listeners, l)
|
||||
return l
|
||||
}
|
||||
|
@ -85,6 +85,13 @@ func (p *EventPool) Add(tag string, data interface{}) {
|
|||
for _, l := range p.listeners {
|
||||
select {
|
||||
case l <- e:
|
||||
// NOTE: Without this 'default', errors in sending the event
|
||||
// to the listener would not empty the channel, therefore
|
||||
// all operations would be stuck at some point (after the first
|
||||
// event if not buffered or after the first N events if buffered)
|
||||
//
|
||||
// See https://github.com/bettercap/bettercap/issues/198
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue