summaryrefslogtreecommitdiff
path: root/evutil.c
diff options
context:
space:
mode:
authoryuangongji <82787816@qq.com>2019-10-18 21:03:40 +0800
committeryuangongji <82787816@qq.com>2019-10-18 21:03:40 +0800
commit879d24961973c2dcf6de64a7e0229adcbad484b7 (patch)
treec2bb748b28ddcfd1e956029380854924c40eabb5 /evutil.c
parentb9b9f19058dc04b7ad4d079a38f6b86c0e7b1072 (diff)
downloadlibevent-879d24961973c2dcf6de64a7e0229adcbad484b7.tar.gz
evutil: make evutil_socketpair() have the same behavior on Windows with build number lower and higher than 17063
Diffstat (limited to 'evutil.c')
-rw-r--r--evutil.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/evutil.c b/evutil.c
index 582b241a..13631263 100644
--- a/evutil.c
+++ b/evutil.c
@@ -229,7 +229,7 @@ evutil_check_working_afunix_()
* socket(AF_UNIX, , ) and fall back to socket(AF_INET, , ).
* https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
*/
- int sd = -1;
+ evutil_socket_t sd = -1;
if (have_working_afunix_ < 0) {
if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
have_working_afunix_ = 0;
@@ -352,13 +352,19 @@ evutil_win_socketpair(int family, int type, int protocol,
EVUTIL_SET_SOCKET_ERROR(WSAEAFNOSUPPORT);
return -1;
}
- if (family == AF_UNIX && evutil_check_working_afunix_()) {
- /* Win10 does not support AF_UNIX socket of a type other
- * than SOCK_STREAM still now. */
- type = SOCK_STREAM;
+ if (evutil_check_working_afunix_()) {
+ /* If the AF_UNIX socket works, we will change the family to
+ * AF_UNIX forcely. */
+ 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 {
- /* If the family is set to AF_UNIX and it does not work,
- * we will change it to AF_UNIX forcely. */
+ /* If the AF_UNIX socket does not work, we will change the
+ * family to AF_INET forcely. */
family = AF_INET;
}
if (family == AF_UNIX)