-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-adding dispatch source for socket file descriptors results in reuse and incorrect update of dispatch_muxnote_t on Ubuntu, Android, and Windows #833
Comments
I am guessing that Windows implementation follows epoll logic, at least in some parts. It also suffers from similar |
Interesting. We have not encountered the issues on Windows, but I'll investigate that too.
Do you have a hotfix for this that's different from mine? |
We workarounded it in Foundation by duplicating sockets with |
Huh forgot that this is actually guaranteed by the API on Linux :)
|
Hi, we created this fix with dub in Foundation to fix the 64K problem but I'm not very happy with it. Mostly, because it leads to over usage of file descriptors in runtime. Android limits FD count to 1024, which may sound reasonable for most applications. But in our application users can add a lot of accounts that will use separate connections and we see that some power users reach this limit from time to time :( That's why we would be glad to see a fix for this issue in libdispatch 👍 |
Creating a dispatch source for a socket file descriptor, removing it, and re-adding it shortly after results in a reuse of the underlying
dispatch_muxnote_t
which was created with the first dispatch source. This happens on Ubuntu 23.10 and Android API 24,34.However, during registration of the new unote in
_dispatch_unote_register_muxed
https://github.com/apple/swift-corelibs-libdispatch/blob/542b7f32311680b11b6fc8fcb2576955460ba7da/src/event/event_epoll.c#L270-L272_dispatch_epoll_update
returnsENOENT
and the existing muxnote is in turn not correctly updated.Sometimes, this is because of https://github.com/apple/swift-corelibs-libdispatch/blob/542b7f32311680b11b6fc8fcb2576955460ba7da/src/event/event_epoll.c#L602-L611
EPOLLHUP
.I also noticed removal of muxnotes which still had an active reader or writer.
Here is a workaround that worked for us:
Here is an example on Android API 34 with head at 542b7f3.
The patch with logging
The text was updated successfully, but these errors were encountered: