mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -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 {
|
func (p *EventPool) Listen() <-chan Event {
|
||||||
p.Lock()
|
p.Lock()
|
||||||
defer p.Unlock()
|
defer p.Unlock()
|
||||||
l := make(chan Event, 255)
|
l := make(chan Event)
|
||||||
p.listeners = append(p.listeners, l)
|
p.listeners = append(p.listeners, l)
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,13 @@ func (p *EventPool) Add(tag string, data interface{}) {
|
||||||
for _, l := range p.listeners {
|
for _, l := range p.listeners {
|
||||||
select {
|
select {
|
||||||
case l <- e:
|
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