1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 00:39:31 +08:00

select with context when sending on channels

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2015-06-12 11:32:06 -07:00
parent 952dc9c60f
commit b12cc09f64

View File

@ -168,11 +168,17 @@ func (mq *msgQueue) runQueue(ctx context.Context) {
} }
func (pm *WantManager) Connected(p peer.ID) { func (pm *WantManager) Connected(p peer.ID) {
pm.connect <- p select {
case pm.connect <- p:
case <-pm.ctx.Done():
}
} }
func (pm *WantManager) Disconnected(p peer.ID) { func (pm *WantManager) Disconnected(p peer.ID) {
pm.disconnect <- p select {
case pm.disconnect <- p:
case <-pm.ctx.Done():
}
} }
// TODO: use goprocess here once i trust it // TODO: use goprocess here once i trust it