Should think of getting rid of race conditions, for now just recover() .
This commit is contained in:
parent
0aaabff503
commit
227dc816fa
1 changed files with 3 additions and 1 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue