mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-09-26 20:21:26 +08:00
basichost: fix deadlock with addrs_manager (#3348)
This commit is contained in:
@@ -623,7 +623,13 @@ func (cfg *Config) NewNode() (host.Host, error) {
|
||||
}
|
||||
|
||||
if cfg.Routing != nil {
|
||||
return &closableRoutedHost{App: app, RoutedHost: rh}, nil
|
||||
return &closableRoutedHost{
|
||||
closableBasicHost: closableBasicHost{
|
||||
App: app,
|
||||
BasicHost: bh,
|
||||
},
|
||||
RoutedHost: rh,
|
||||
}, nil
|
||||
}
|
||||
return &closableBasicHost{App: app, BasicHost: bh}, nil
|
||||
}
|
||||
|
@@ -20,11 +20,14 @@ func (h *closableBasicHost) Close() error {
|
||||
}
|
||||
|
||||
type closableRoutedHost struct {
|
||||
*fx.App
|
||||
// closableBasicHost is embedded here so that interface assertions on
|
||||
// BasicHost exported methods work correctly.
|
||||
closableBasicHost
|
||||
*routed.RoutedHost
|
||||
}
|
||||
|
||||
func (h *closableRoutedHost) Close() error {
|
||||
_ = h.App.Stop(context.Background())
|
||||
// The routed host will close the basic host
|
||||
return h.RoutedHost.Close()
|
||||
}
|
||||
|
Reference in New Issue
Block a user