File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -301,16 +301,14 @@ func (e *endpoint) Dispose() (err error) {
301301 defer e .Unlock ()
302302
303303 prevfd := e .fds .Swap (invalidFds ) // prevfd may be invalidfd
304- if ! prevfd .ok () {
305- log .W ("ns: tun: Dispose: invalid prevfd" )
306- return nil
307- }
308304
309305 if e .inboundDispatcher == nil {
310- log .W ("ns: tun: Dispose: no inbound dispatcher" )
306+ prevfd .stop () // prevfd may be invalidfd
307+ log .W ("ns: tun: Dispose: %d; no inbound dispatcher" , prevfd .tun ())
311308 // nothing to do
312309 return nil
313310 }
311+
314312 // e.inboundDispatcher.prepare() will not close prevfd
315313 // dispatchLoop() will auto-exit on invalidfd
316314 core .Go ("ns.dispose.wrapup" , func () { e .inboundDispatcher .wrapup (prevfd , wrapttl ) })
@@ -398,6 +396,9 @@ func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) {
398396 var err error
399397 e .inboundDispatcher , err = createInboundDispatcher (e , fds )
400398 logeif (err )("ns: tun(%d): attach: just-in-time createInboundDispatcher; err? %v" , fd , err )
399+ if e .inboundDispatcher != nil {
400+ e .inboundDispatcher .prepare (fds )
401+ }
401402 rx = e .inboundDispatcher
402403 }
403404 go dispatchLoop (rx , fds , & e .wg )
You can’t perform that action at this time.
0 commit comments