mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-01 14:18:36 +00:00
Ignore closed and canceled errors in scope cleanup
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/sagernet/sing-box/common/taskmonitor"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing/common"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
F "github.com/sagernet/sing/common/format"
|
||||
)
|
||||
@@ -131,11 +132,13 @@ func (s *Scope) Close() error {
|
||||
s.cleanups = nil
|
||||
s.children = nil
|
||||
s.access.Unlock()
|
||||
var err error
|
||||
var cleanupErrors []error
|
||||
for _, cleanup := range slices.Backward(cleanups) {
|
||||
err = E.Errors(err, cleanup())
|
||||
cleanupErrors = append(cleanupErrors, E.Expand(cleanup())...)
|
||||
}
|
||||
return err
|
||||
return E.Errors(common.Filter(cleanupErrors, func(it error) bool {
|
||||
return !E.IsClosed(it) && !E.IsCanceled(it)
|
||||
})...)
|
||||
}
|
||||
|
||||
func LogElapsed(logger log.ContextLogger, description ...any) func() {
|
||||
|
||||
Reference in New Issue
Block a user