mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-07 10:42:38 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user