Closed yoursunny closed 2 years ago
@zjkmxy any idea why handleIncomingFrame
is called before Run
?
Reversing the order won't help because Run
is in a new goroutine.
You need to create l.stealthPool
in MakeNDNLPLinkService
so that it's always there.
@zjkmxy any idea why
handleIncomingFrame
is called beforeRun
?
UDP face is created upon reception of a packet. Thus that packet must be submitted to the face.
In current implementation, Run()
is run as a coroutine, and there is no way to wait until the creation of l.stealthPool
without refactoring the interface.
Reversing the order won't help because
Run
is in a new goroutine. You need to createl.stealthPool
inMakeNDNLPLinkService
so that it's always there.
Actually they did this at the beginning. But they wanted to defer the destruction of stealthpool.
Currently, there is no function such as LinkService.Close()
, so they moved the function into Run()
.
You still can defer l.stealthPool.Close()
in the Run
function.
I think a couple of solutions:
1/ Make the stealthpool create on first use. As long as Run()
is called at some point, we don't have a memleak.
2/ Get rid of it altogether. It's really meant to reduce just one copy, not sure it makes too big a difference.
The stealthPool has nothing to do with "to reduce one copy". It's for reducing GC overhead.
I think you can just use a global sync.Pool
.
When YaNFD version e12c57105546d5e8bb1c005fdecfb5f150c4c298 receives an incoming UDP packet, it crashes with the following error:
The cause is:
NDNLPLinkService
type,l.stealthPool
is initialized inRun
method and used inhandleIncomingFrame
method.UDPListener
type,handleIncomingFrame
is called beforeRun
.