mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
evutil: make evutil_socketpair() have the same behavior on Windows with build number lower and higher than 17063
This commit is contained in:
parent
b9b9f19058
commit
879d249619
20
evutil.c
20
evutil.c
@ -229,7 +229,7 @@ evutil_check_working_afunix_()
|
|||||||
* socket(AF_UNIX, , ) and fall back to socket(AF_INET, , ).
|
* socket(AF_UNIX, , ) and fall back to socket(AF_INET, , ).
|
||||||
* https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
|
* https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
|
||||||
*/
|
*/
|
||||||
int sd = -1;
|
evutil_socket_t sd = -1;
|
||||||
if (have_working_afunix_ < 0) {
|
if (have_working_afunix_ < 0) {
|
||||||
if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||||
have_working_afunix_ = 0;
|
have_working_afunix_ = 0;
|
||||||
@ -352,13 +352,19 @@ evutil_win_socketpair(int family, int type, int protocol,
|
|||||||
EVUTIL_SET_SOCKET_ERROR(WSAEAFNOSUPPORT);
|
EVUTIL_SET_SOCKET_ERROR(WSAEAFNOSUPPORT);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (family == AF_UNIX && evutil_check_working_afunix_()) {
|
if (evutil_check_working_afunix_()) {
|
||||||
/* Win10 does not support AF_UNIX socket of a type other
|
/* If the AF_UNIX socket works, we will change the family to
|
||||||
* than SOCK_STREAM still now. */
|
* AF_UNIX forcely. */
|
||||||
type = SOCK_STREAM;
|
family = AF_UNIX;
|
||||||
|
if (type != SOCK_STREAM) {
|
||||||
|
/* Win10 does not support AF_UNIX socket of a type other
|
||||||
|
* than SOCK_STREAM still now. */
|
||||||
|
EVUTIL_SET_SOCKET_ERROR(WSAEAFNOSUPPORT);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* If the family is set to AF_UNIX and it does not work,
|
/* If the AF_UNIX socket does not work, we will change the
|
||||||
* we will change it to AF_UNIX forcely. */
|
* family to AF_INET forcely. */
|
||||||
family = AF_INET;
|
family = AF_INET;
|
||||||
}
|
}
|
||||||
if (family == AF_UNIX)
|
if (family == AF_UNIX)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user