Skip to content
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

CFSocket should use dynamically-sized fd_set on Windows #4958

Open
tristanlabelle opened this issue May 16, 2024 · 0 comments · May be fixed by #4969
Open

CFSocket should use dynamically-sized fd_set on Windows #4958

tristanlabelle opened this issue May 16, 2024 · 0 comments · May be fixed by #4969

Comments

@tristanlabelle
Copy link
Contributor

The fd_set structure on Windows has a trailing array of socket that defaults to size 64, which we override to 1024 https://github.com/apple/swift-corelibs-foundation/blob/06072877b110c4ba5501ddc012830c1072f7198c/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h#L133C1-L133C24 .

Instead of using a large fixed-sized buffer, we can treat the structure as dynamically-sized and reallocate it when it gets full. Winsock functions read the size of the array from the count field in order to support the array to exceed 64 as needed. The only caveat is that we can't use the FD_SET macro because it has to use the compile-time size.

lxbndr added a commit to readdle/swift-corelibs-foundation that referenced this issue Jun 4, 2024
This makes `fd_set` on Windows growable by adding additional space to the storing buffer, which effectively extends `fd_set.fd_array` capacity.
Follow-up for swiftlang#4954. Resolves swiftlang#4958.
@lxbndr lxbndr linked a pull request Jun 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant