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