basichost: fix deadlock with addrs_manager (#3348)

This commit is contained in:
sukun
2025-07-30 17:08:12 +05:30
committed by GitHub
parent 8e8f76abf6
commit 26a5710d35
7 changed files with 96 additions and 38 deletions

View File

@@ -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
}

View File

@@ -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()
}