Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 8a548d15292f2166cb07a69fc5fc943391b7fba5 https://github.com/Perl/perl5/commit/8a548d15292f2166cb07a69fc5fc943391b7fba5 Author: Tomasz Konojacki <me@xenu.pl> Date: 2023-03-17 (Fri, 17 Mar 2023) Changed paths: M win32/win32.c M win32/win32.h M win32/win32sck.c Log Message: ----------- win32: initialise winsock unconditionally The next commit needs it. Also, I don't think this optimisation is worth the trouble. Commit: 8552f09f5cfe61a536a65f11290ef026f7aa0356 https://github.com/Perl/perl5/commit/8552f09f5cfe61a536a65f11290ef026f7aa0356 Author: Tomasz Konojacki <me@xenu.pl> Date: 2023-03-17 (Fri, 17 Mar 2023) Changed paths: M pod/perldelta.pod M win32/win32.c M win32/win32.h M win32/win32sck.c Log Message: ----------- win32: inject a socket-aware version of CloseHandle() into the CRT _close() on an fd calls CloseHandle(), which is illegal if the fd contains a socket handle. We previously worked around this by having our own close(), which called closesocket() before calling _close() (e601c439adce167078ac7b49550c0418ace86f94). Amusingly, the author of that solution thought it's just a temporary workaround: /* * close RTL fd while respecting sockets * added as temporary measure until PerlIO has real * Win32 native layer * -- BKS, 11-11-2000 */ To make it thread-safe, we had to manipulate the internals of file descriptors, which kept changing (b47a847f6284f6f98ad7509cf77a4aeb802d8fce). Unfortunately, the C runtime has been rewritten and it no longer exposes them at all. We had to disable the thread-safety fix in Visual C++ 2015 builds (1f664ef5314fb6e438137c44c95cf5ecdbdb5e9b). It also wouldn't work with MinGW configured to use UCRT. This commit introduces a new solution: we inject a socket-aware version of CloseHandle() into the C runtime library. Hopefully, this will be less fragile. This also fixes a few issues that the original solution didn't: - Closing a busy pipe doesn't cause a deadlock (fixes #19963) - _dup2 properly closes an overwritten socket (fixes #20920) Compare: https://github.com/Perl/perl5/compare/c1cac033a542...8552f09f5cfe