Close stack faster

This commit is contained in:
世界 2022-07-31 19:55:51 +08:00
parent d5dd3b3bb1
commit 4a805410a2
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 3 additions and 3 deletions

View file

@ -30,6 +30,7 @@ type GVisorTun struct {
endpointIndependentNatTimeout int64 endpointIndependentNatTimeout int64
handler Handler handler Handler
stack *stack.Stack stack *stack.Stack
endpoint stack.LinkEndpoint
} }
func NewGVisor( func NewGVisor(
@ -158,10 +159,12 @@ func (t *GVisorTun) Start() error {
} }
t.stack = ipStack t.stack = ipStack
t.endpoint = linkEndpoint
return nil return nil
} }
func (t *GVisorTun) Close() error { func (t *GVisorTun) Close() error {
t.endpoint.Attach(nil)
t.stack.Close() t.stack.Close()
for _, endpoint := range t.stack.CleanupEndpoints() { for _, endpoint := range t.stack.CleanupEndpoints() {
endpoint.Abort() endpoint.Abort()

View file

@ -63,9 +63,6 @@ func (m *networkUpdateMonitor) Start() error {
if err != nil { if err != nil {
return err return err
} }
if err != nil {
return err
}
go m.loopUpdate() go m.loopUpdate()
return nil return nil
} }