mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 07:57:30 +08:00
select with context when sending on channels
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
@ -168,11 +168,17 @@ func (mq *msgQueue) runQueue(ctx context.Context) {
|
||||
}
|
||||
|
||||
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) {
|
||||
pm.disconnect <- p
|
||||
select {
|
||||
case pm.disconnect <- p:
|
||||
case <-pm.ctx.Done():
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: use goprocess here once i trust it
|
||||
|
Reference in New Issue
Block a user