mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 09:16:58 +08:00
Fix: wait for device to close
This commit is contained in:
@@ -17,4 +17,7 @@ type Device interface {
|
||||
|
||||
// Type returns the driver type of the device.
|
||||
Type() string
|
||||
|
||||
// Wait waits for the device to close.
|
||||
Wait()
|
||||
}
|
||||
|
@@ -79,5 +79,6 @@ func (t *TUN) Name() string {
|
||||
}
|
||||
|
||||
func (t *TUN) Close() error {
|
||||
t.Endpoint.Close()
|
||||
return t.nt.Close()
|
||||
}
|
||||
|
@@ -80,13 +80,16 @@ func (e *engine) start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *engine) stop() error {
|
||||
func (e *engine) stop() (err error) {
|
||||
if e.device != nil {
|
||||
return e.device.Close()
|
||||
err = e.device.Close()
|
||||
e.device.Wait()
|
||||
}
|
||||
if e.stack != nil {
|
||||
e.stack.Close()
|
||||
e.stack.Wait()
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (e *engine) insert(k *Key) {
|
||||
|
Reference in New Issue
Block a user