Fix build on windows xp
Windows XP doesn't support setting socket handles to be non-inheritable, but the rio_notifier attempts to do so. WSASocketA will there return an error when the NO_INHERIT flag is set. In that case, just retry the call without the flag. Fixes #26943 Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/26970)
This commit is contained in:
parent
6e7be995fd
commit
c0251d7b0f
1 changed files with 18 additions and 0 deletions
|
@ -71,9 +71,27 @@ static int create_socket(int domain, int socktype, int protocol)
|
|||
* Use WSASocketA to create a socket which is immediately marked as
|
||||
* non-inheritable, avoiding race conditions if another thread is about to
|
||||
* call CreateProcess.
|
||||
* NOTE: windows xp (0x501) doesn't support the non-inheritance flag here
|
||||
* but preventing inheritance isn't mandatory, just a safety precaution
|
||||
* so we can get away with not including it for older platforms
|
||||
*/
|
||||
|
||||
# ifdef WSA_FLAG_NO_HANDLE_INHERIT
|
||||
fd = (int)WSASocketA(domain, socktype, protocol, NULL, 0,
|
||||
WSA_FLAG_NO_HANDLE_INHERIT);
|
||||
|
||||
/*
|
||||
* Its also possible that someone is building a binary on a newer windows
|
||||
* SDK, but running it on a runtime that doesn't support inheritance
|
||||
* supression. In that case the above will return INVALID_SOCKET, and
|
||||
* our response for those older platforms is to try the call again
|
||||
* without the flag
|
||||
*/
|
||||
if (fd == INVALID_SOCKET)
|
||||
fd = (int)WSASocketA(domain, socktype, protocol, NULL, 0, 0);
|
||||
# else
|
||||
fd = (int)WSASocketA(domain, socktype, protocol, NULL, 0, 0);
|
||||
# endif
|
||||
if (fd == INVALID_SOCKET) {
|
||||
int err = get_last_socket_error();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue