File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -102,15 +102,18 @@ 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
107105func (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+ r .refcount .Add (1 )
108+ go func () {
109+ defer r .refcount .Done ()
110+ select {
111+ case r .triggerRefresh <- & triggerRefreshReq {respCh : resp , forceCplRefresh : force }:
112+ case <- r .ctx .Done ():
113+ resp <- r .ctx .Err ()
114+ }
115+ }()
116+
114117 return resp
115118}
116119
You can’t perform that action at this time.
0 commit comments