Repository navigation
Close a UDP proxy backend that becomes active after eviction - #2019
devops-thiago wants to merge 1 commit into
Conversation
0467f24 to
510e87b
Compare
510e87b to
99a61ac
Compare
|
@katiewasnothere I noticed you labeled #2015 I have three other small parser fixes open with the same setup — #2016, #2017, #2018 — each one line plus a test, each with a linked issue. All four are rebased onto current main, signed, and pass the unit suite. Since I don't have a merged PR yet, the workflows are waiting on approval to run. If you're able to approve them, that would unblock CI on the set. Happy to adjust anything. |
99a61ac to
861350b
Compare
861350b to
d34e41d
Compare
|
@egernst Pinging you since you fixed a closely related bug in #2260 ( Three other small parser fixes are open with the same setup — #2016, #2017, #2018 — each one line plus a test, each with a linked issue. All four (plus four unrelated fixes: #2090, #2091, #2092, #2093) are rebased onto current main, signed, and passing the unit suite. I don't have a merged PR yet, so the workflows are stuck waiting on approval to run. An approve on any of these would unblock CI for the rest. |
d34e41d to
133f4aa
Compare
|
@jglogan I pinged @katiewasnothere on Sep 2 and @egernst on Sep 14 about this same batch with no reply, so per the contributing guide I'm trying someone else. Eight small PRs are open, all rebased onto current main, signed, and passing the unit suite: #2016, #2017, #2018, #2019 (parser/proxy fixes, each one line plus a test) and #2090, #2091, #2092, #2093 (exit code persistence, XPC peer validation, image list filtering, build context error reporting). None have a review yet, so CI is stuck waiting on approval to run. An approve on any one would unblock the workflows for the rest. Happy to split these up, add more tests, or adjust anything that doesn't fit. |
133f4aa to
b883996
Compare
UDPProxyBackend.close() returned early when the backend channel had not finished binding, leaving the socket open. The frontend calls close() on whichever backend the LRU cache evicts, so a backend evicted inside the bind window was never closed: channelActive then adopted the channel, and because the ProxyContext had already been dropped from the cache, no reference remained that could close it. The socket stayed open for the lifetime of the process. Record the close request in the backend state and have channelActive honour it, closing the channel instead of adopting it. Both paths run on the event loop the backend is bootstrapped on, so the flag needs no additional synchronisation. UDPProxyBackend becomes internal so the regression test can drive the eviction ordering directly. Fixes apple#2015
b883996 to
fc39bc9
Compare
|
Closing this together with #2015, which I could not reproduce on a real daemon (details there). The |
Type of Change
Motivation and Context
Fixes #2015.
UDPProxyFrontendkeeps at most 256 backends in an LRU cache and closes whichever one is evicted.UDPProxyBackend.close()returned early when the backend channel had not finished binding:state.channelis nil from construction untilchannelActiveruns, which happens afterbindcompletes. A backend evicted inside that window is never closed.channelActivethen adopts the channel, and because theProxyContexthas already been dropped from the cache, no reference remains that could close it. The socket stays open for the lifetime of the process.The existing warning shows the case was anticipated, but the early return leaves the socket open rather than deferring the close.
This change records the close request in the backend state and has
channelActivehonour it, closing the channel instead of adopting it and discarding any queued payloads. Both paths run on the event loop the backend is bootstrapped on, sinceDatagramBootstrap(group: context.eventLoop)andNIOLoopBound(proxy, eventLoop: context.eventLoop)bind them to that loop, so the flag needs no further synchronisation.UDPProxyBackendchanges from file-private to internal so the test can drive the ordering directly. Nothing outside the module references it.Testing
testBackendClosedBeforeChannelActiveClosesTheChannelcallsclose()before the channel becomes active, then activates it through anEmbeddedChanneland asserts the channel is no longer active. The test fails against the current code and passes with this change.testUDPForwarderandtestLRUCachecontinue to pass.