Fix ticker leak in campaign manager message push

This commit is contained in:
Kailash Nadh 2020-07-06 20:29:19 +05:30
parent fd044f4cb6
commit c2613d1030
1 changed files with 4 additions and 1 deletions

View File

@ -157,9 +157,12 @@ func (m *Manager) AddMessenger(msg messenger.Messenger) error {
// PushMessage pushes a Message to be sent out by the workers.
func (m *Manager) PushMessage(msg Message) error {
t := time.NewTicker(time.Second * 3)
defer t.Stop()
select {
case m.msgQueue <- msg:
case <-time.After(time.Second * 3):
case <-t.C:
m.logger.Println("message push timed out: %'s'", msg.Subject)
return errors.New("message push timed out")
}