Skip to content

Commit 3d2c8dc

Browse files
committed
netstack: opportunisitcally create inbound-dispatcher in Attach
1 parent f730757 commit 3d2c8dc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

intra/netstack/fdbased.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) {
328328
if dispatcher != nil && e.dispatcher == nil {
329329
log.I("ns: tun(%d): attach: new dispatcher & looper", fd)
330330
e.dispatcher = dispatcher
331+
if e.inboundDispatcher == nil && fd != invalidfd { // unlikely
332+
var err error
333+
e.inboundDispatcher, err = createInboundDispatcher(e, fd)
334+
logeif(err)("ns: tun(%d): attach: just-in-time createInboundDispatcher; err? %v", fd, err)
335+
rx = e.inboundDispatcher
336+
}
331337
go e.dispatchLoop(rx)
332338
return
333339
}

0 commit comments

Comments
 (0)