aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-05-17 16:43:30 +0200
committerMicael Karlberg <[email protected]>2019-05-29 13:47:40 +0200
commit12e99364db99e336d5382510241f47e40e0db9af (patch)
tree10dc067af735fcbdeb1abe134fc5ff32c13d81ac
parent3e2c3eec258b1ea13affe91db0451f3737983306 (diff)
downloadotp-12e99364db99e336d5382510241f47e40e0db9af.tar.gz
otp-12e99364db99e336d5382510241f47e40e0db9af.tar.bz2
otp-12e99364db99e336d5382510241f47e40e0db9af.zip
[esock|test] On some platforms recvmsg does *not* return address
On some platforms, e.g. FreeBSD, recvmsg does *not* return address for a Unix Domain (stream) socket. Unlike, for instance, on Linux. OTP-15822
-rw-r--r--erts/emulator/nifs/common/socket_nif.c4
-rw-r--r--erts/emulator/test/socket_SUITE.erl36
2 files changed, 37 insertions, 3 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 340111f76c..2562399fd0 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -15224,8 +15224,8 @@ char* encode_msghdr(ErlNifEnv* env,
"\r\n read: %d"
"\r\n", read) );
- /* The address is not used if we are connected (unless family is 'local'),
- * so check (length = 0) before we try to encodel
+ /* The address is not used if we are connected (unless, maybe,
+ * family is 'local'), so check (length = 0) before we try to encodel
*/
if (msgHdrP->msg_namelen != 0) {
if ((xres = esock_encode_sockaddr(env,
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index 337a34c0d2..b420acd57c 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -2156,10 +2156,25 @@ api_b_sendmsg_and_recvmsg_tcpL(_Config) when is_list(_Config) ->
end,
Recv = fun(Sock) ->
case socket:recvmsg(Sock) of
+ %% On some platforms, the address
+ %% is *not* provided (e.g. FreeBSD)
+ {ok, #{addr := undefined,
+ iov := [Data]}} ->
+ {ok, Data};
+ %% On some platforms, the address
+ %% *is* provided (e.g. linux)
{ok, #{addr := #{family := local},
iov := [Data]}} ->
+ socket:setopt(Sock,
+ otp,
+ debug,
+ false),
{ok, Data};
{error, _} = ERROR ->
+ socket:setopt(Sock,
+ otp,
+ debug,
+ false),
ERROR
end
end,
@@ -9539,6 +9554,13 @@ sc_rs_recvmsg_send_shutdown_receive_tcpL(_Config) when is_list(_Config) ->
MsgData = ?DATA,
Recv = fun(Sock) ->
case socket:recvmsg(Sock) of
+ %% On some platforms, the address
+ %% is *not* provided (e.g. FreeBSD)
+ {ok, #{addr := undefined,
+ iov := [Data]}} ->
+ {ok, Data};
+ %% On some platforms, the address
+ %% *is* provided (e.g. linux)
{ok, #{addr := #{family := local},
iov := [Data]}} ->
{ok, Data};
@@ -11472,6 +11494,13 @@ traffic_ping_pong_send_and_recv_tcp(InitState) ->
traffic_ping_pong_sendmsg_and_recvmsg_tcp(#{domain := local} = InitState) ->
Recv = fun(Sock, Sz) ->
case socket:recvmsg(Sock, Sz, 0) of
+ %% On some platforms, the address
+ %% is *not* provided (e.g. FreeBSD)
+ {ok, #{addr := undefined,
+ iov := [Data]}} ->
+ {ok, Data};
+ %% On some platforms, the address
+ %% *is* provided (e.g. linux)
{ok, #{addr := #{family := local},
iov := [Data]}} ->
{ok, Data};
@@ -19932,7 +19961,12 @@ has_support_unix_domain_socket() ->
{win32, _} ->
{skip, "Not supported"};
_ ->
- ok
+ case socket:supports(local) of
+ true ->
+ ok;
+ false ->
+ {skip, "Not supported"}
+ end
end.