diff options
author | Micael Karlberg <[email protected]> | 2018-10-04 10:06:16 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-10-04 10:06:16 +0200 |
commit | 4b1e1e148a5cc9c19127b61aaa3e15eeeaea6cb2 (patch) | |
tree | 26621f8cca51051dda15027260c836783e916f7f /erts/preloaded/src | |
parent | 1c412c62ba3be17b7a818f264049a7ee7942351e (diff) | |
download | otp-4b1e1e148a5cc9c19127b61aaa3e15eeeaea6cb2.tar.gz otp-4b1e1e148a5cc9c19127b61aaa3e15eeeaea6cb2.tar.bz2 otp-4b1e1e148a5cc9c19127b61aaa3e15eeeaea6cb2.zip |
[socket-nif] Socket option 'SO_DOMAIN' not avalable on all platforms
Internally in the socket module we accessed domain, type and
protocol for an open socket. But as it turns out, domain (family)
is not actually available as a socket option on all platforms.
FreeBSD in this case. So, since we store these values in the socket
descriptor anyway, we switch to use these values for our internal
use instead.
OTP-14831
Diffstat (limited to 'erts/preloaded/src')
-rw-r--r-- | erts/preloaded/src/socket.erl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index 8093bad885..c388fc2849 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -652,6 +652,9 @@ %%-define(SOCKET_OPT_OTP_SNDBUF, 5). -define(SOCKET_OPT_OTP_RCVCTRLBUF, 6). -define(SOCKET_OPT_OTP_SNDCTRLBUF, 7). +-define(SOCKET_OPT_OTP_DOMAIN, 16#FF01). % INTERNAL +-define(SOCKET_OPT_OTP_TYPE, 16#FF02). % INTERNAL +-define(SOCKET_OPT_OTP_PROTOCOL, 16#FF03). % INTERNAL %% *** SOCKET (socket) options -define(SOCKET_OPT_SOCK_ACCEPTCONN, 1). @@ -2159,7 +2162,7 @@ getopt(#socket{ref = SockRef}, Level, Key) -> which_domain(SockRef) -> case nif_getopt(SockRef, true, - ?SOCKET_OPT_LEVEL_SOCKET, ?SOCKET_OPT_SOCK_DOMAIN) of + ?SOCKET_OPT_LEVEL_OTP, ?SOCKET_OPT_OTP_DOMAIN) of {ok, Domain} -> Domain; {error, _} = ERROR -> @@ -2173,7 +2176,7 @@ which_domain(SockRef) -> which_type(SockRef) -> case nif_getopt(SockRef, true, - ?SOCKET_OPT_LEVEL_SOCKET, ?SOCKET_OPT_SOCK_TYPE) of + ?SOCKET_OPT_LEVEL_OTP, ?SOCKET_OPT_OTP_TYPE) of {ok, Type} -> Type; {error, _} = ERROR -> @@ -2186,9 +2189,9 @@ which_type(SockRef) -> which_protocol(SockRef) -> case nif_getopt(SockRef, true, - ?SOCKET_OPT_LEVEL_SOCKET, ?SOCKET_OPT_SOCK_PROTOCOL) of - {ok, Type} -> - Type; + ?SOCKET_OPT_LEVEL_OTP, ?SOCKET_OPT_OTP_PROTOCOL) of + {ok, Proto} -> + Proto; {error, _} = ERROR -> throw(ERROR) end. |