Eliminate busy-loop in dispatchOutbound when context is cancelled
This commit is contained in:
parent
214b201bfa
commit
d7084052b7
1 changed files with 21 additions and 26 deletions
|
|
@ -246,14 +246,10 @@ func (m *Manager) dispatchOutbound(ctx context.Context) {
|
||||||
logger.InfoC("channels", "Outbound dispatcher started")
|
logger.InfoC("channels", "Outbound dispatcher started")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
logger.InfoC("channels", "Outbound dispatcher stopped")
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
msg, ok := m.bus.SubscribeOutbound(ctx)
|
msg, ok := m.bus.SubscribeOutbound(ctx)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
logger.InfoC("channels", "Outbound dispatcher stopped")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Silently skip internal channels
|
// Silently skip internal channels
|
||||||
|
|
@ -280,7 +276,6 @@ func (m *Manager) dispatchOutbound(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Manager) GetChannel(name string) (Channel, bool) {
|
func (m *Manager) GetChannel(name string) (Channel, bool) {
|
||||||
m.mu.RLock()
|
m.mu.RLock()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue