Skip to content

Commit 980c6ad

Browse files
aarshkshah1992Stebalien
authored andcommitted
unblock refresh
1 parent a8d4bf3 commit 980c6ad

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

rtrefresh/rt_refresh_manager.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ func (r *RtRefreshManager) Close() error {
102102
//
103103
// The returned channel will block until the refresh finishes, then yield the
104104
// error and close. The channel is buffered and safe to ignore.
105-
// FIXME: this can block. Ideally, we'd return a channel without blocking.
106-
// https://github.com/libp2p/go-libp2p-kad-dht/issues/609
107105
func (r *RtRefreshManager) Refresh(force bool) <-chan error {
108106
resp := make(chan error, 1)
109-
select {
110-
case r.triggerRefresh <- &triggerRefreshReq{respCh: resp, forceCplRefresh: force}:
111-
case <-r.ctx.Done():
112-
resp <- r.ctx.Err()
113-
}
107+
go func() {
108+
select {
109+
case r.triggerRefresh <- &triggerRefreshReq{respCh: resp, forceCplRefresh: force}:
110+
case <-r.ctx.Done():
111+
resp <- r.ctx.Err()
112+
}
113+
}()
114+
114115
return resp
115116
}
116117

0 commit comments

Comments
 (0)