Inbound: Close and remove the handler when it fails to start (#7223)

https://github.com/XTLS/Xray-core/pull/7223#pullrequestreview-5722817769

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
Hamed Yousefi
2026-11-06 17:57:42 +00:00
committed by GitHub
co-authored by 风扇滑翔翼
parent bb335c6b0c
commit 2e4c13d8c4
+11 -1
View File
@@ -51,7 +51,17 @@ func (m *Manager) AddHandler(ctx context.Context, handler inbound.Handler) error
}
if m.running {
return handler.Start()
if err := handler.Start(); err != nil {
if len(tag) > 0 {
delete(m.taggedHandlers, tag)
} else {
m.untaggedHandlers = m.untaggedHandlers[:len(m.untaggedHandlers)-1]
}
if err := handler.Close(); err != nil {
errors.LogWarningInner(ctx, err, "failed to close handler ", tag)
}
return err
}
}
return nil