apple / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.23k stars 1.12k forks source link

[Windows] Dynamic `fd_set` in `CFSocket` #4969

Open lxbndr opened 1 month ago

lxbndr commented 1 month ago

This makes fd_set on Windows growable by adding additional space to the storing buffer, which effectively extends fd_set.fd_array capacity.

With this change fixed FD_SETSIZE 1024 becomes unnecessarily large (every such fd_set takes more than 8Kb of memory), so it seems reasonable to reduce it to lower value. I guess 128 will do (which is twice as big as default 64).

Also, I removed some unused defines left from old bit-field implementation and tossed local vars in __CFSocketManager function to make them available according to their usage per platform.

Follow-up for #4954. Resolves #4958.

lxbndr commented 1 month ago

cc @tristanlabelle