aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs/common
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-05-15 15:12:23 +0200
committerMicael Karlberg <[email protected]>2019-05-29 13:47:40 +0200
commit04ce3ab360b97d3683d4692e0e354a9767106881 (patch)
treee497e310409f78033ea4c154612dbda4bf99bde7 /erts/emulator/nifs/common
parentd6ffa270a5ab6cb1967d51a00108d2b4d8bca47f (diff)
downloadotp-04ce3ab360b97d3683d4692e0e354a9767106881.tar.gz
otp-04ce3ab360b97d3683d4692e0e354a9767106881.tar.bz2
otp-04ce3ab360b97d3683d4692e0e354a9767106881.zip
[esock] SO_PROTOCOL does not exist on darwin (18.2.0)
The flag SO_PROTOCOL does not exist on darwin 18.2.0 (atleast). So, creating a socket with domain =/= local using the default protocol does not work in this case. OTP-15822
Diffstat (limited to 'erts/emulator/nifs/common')
-rw-r--r--erts/emulator/nifs/common/socket_nif.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index d8203f3b91..a62914d730 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -660,6 +660,9 @@ typedef union {
#define SOCKET_SUPPORTS_SCTP 0x0002
#define SOCKET_SUPPORTS_IPV6 0x0003
+#define ESOCK_WHICH_PROTO_ERROR -1
+#define ESOCK_WHICH_PROTO_UNSUP -2
+
/* =================================================================== *
@@ -4465,9 +4468,16 @@ ERL_NIF_TERM nopen(ErlNifEnv* env,
if ((proto != 0) && (domain != AF_LOCAL))
if (!nopen_which_protocol(sock, &proto)) {
- save_errno = sock_errno();
- while ((sock_close(sock) == INVALID_SOCKET) && (sock_errno() == EINTR));
- return esock_make_error_errno(env, save_errno);
+ if (proto == ESOCK_WHICH_PROTO_ERROR) {
+ save_errno = sock_errno();
+ while ((sock_close(sock) == INVALID_SOCKET) &&
+ (sock_errno() == EINTR));
+ return esock_make_error_errno(env, save_errno);
+ } else {
+ while ((sock_close(sock) == INVALID_SOCKET) &&
+ (sock_errno() == EINTR));
+ return esock_make_error(env, esock_atom_eafnosupport);
+ }
}
@@ -4544,6 +4554,7 @@ ERL_NIF_TERM nopen(ErlNifEnv* env,
static
BOOLEAN_T nopen_which_protocol(SOCKET sock, int* proto)
{
+#if defined(SO_PROTOCOL)
int val;
SOCKOPTLEN_T valSz = sizeof(val);
int res;
@@ -4551,11 +4562,16 @@ BOOLEAN_T nopen_which_protocol(SOCKET sock, int* proto)
res = sock_getopt(sock, SOL_SOCKET, SO_PROTOCOL, &val, &valSz);
if (res != 0) {
+ *proto = ESOCK_WHICH_PROTO_ERROR;
return FALSE;
} else {
*proto = val;
return TRUE;
}
+#else
+ *proto = ESOCK_WHICH_PROTO_UNSUP;
+ return FALSE;
+#endif
}
@@ -16303,8 +16319,6 @@ char* encode_cmsghdr_data_ipv6(ErlNifEnv* env,
size_t dataLen,
ERL_NIF_TERM* eCMsgHdrData)
{
- char* xres;
-
switch (type) {
#if defined(IPV6_PKTINFO)
case IPV6_PKTINFO:
@@ -16312,6 +16326,7 @@ char* encode_cmsghdr_data_ipv6(ErlNifEnv* env,
struct in6_pktinfo* pktInfoP = (struct in6_pktinfo*) dataP;
ERL_NIF_TERM ifIndex = MKI(env, pktInfoP->ipi6_ifindex);
ERL_NIF_TERM addr;
+ char* xres;
if ((xres = esock_encode_ip6_address(env,
&pktInfoP->ipi6_addr,