Should think of getting rid of race conditions, for now just recover() .

This commit is contained in:
Andrey Parhomenko 2023-09-28 08:15:57 +03:00
parent 0aaabff503
commit 227dc816fa

View file

@ -20,6 +20,7 @@ func (updates *UpdateChan) Chan() chan *Update {
// Send an update to the channel.
// Returns true if the update was sent.
func (updates *UpdateChan) Send(u *Update) bool {
defer recover()
if updates == nil || updates.chn == nil {
return false
}
@ -45,7 +46,8 @@ func (updates *UpdateChan) Close() {
if updates == nil || updates.chn == nil {
return
}
close(updates.chn)
chn := updates.chn
updates.chn = nil
close(chn)
}