aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-01-21 14:46:07 +0100
committerMicael Karlberg <[email protected]>2019-01-21 14:46:07 +0100
commit8a820377bb3e2e506cdff6011057d78507544142 (patch)
tree042a5d758901f33e9c59e3c8854eea1cc9277937 /erts/preloaded
parent2fb8288e182116180c977aa2c623d066171f6c16 (diff)
downloadotp-8a820377bb3e2e506cdff6011057d78507544142.tar.gz
otp-8a820377bb3e2e506cdff6011057d78507544142.tar.bz2
otp-8a820377bb3e2e506cdff6011057d78507544142.zip
[socket-nif] Add support for otp option fd
Add a way to *get* the file descriptor (fd) of a socket. Useful mostly for debugging. OTP-15528
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/ebin/socket.beambin70272 -> 70344 bytes
-rw-r--r--erts/preloaded/src/socket.erl25
2 files changed, 8 insertions, 17 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index ddd50fdefa..06e7c2910d 100644
--- a/erts/preloaded/ebin/socket.beam
+++ b/erts/preloaded/ebin/socket.beam
Binary files differ
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 2e295a91ae..839087ef2a 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2018-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2018-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -41,12 +41,10 @@
send/2, send/3, send/4,
sendto/3, sendto/4, sendto/5,
sendmsg/2, sendmsg/3, sendmsg/4,
- %% writev/4, OR SENDV? It will be strange for recv then: recvv (instead of readv)
recv/1, recv/2, recv/3, recv/4,
recvfrom/1, recvfrom/2, recvfrom/3, recvfrom/4,
recvmsg/1, recvmsg/2, recvmsg/3, recvmsg/5,
- %% readv/3,
close/1,
shutdown/2,
@@ -164,16 +162,6 @@
0..65535,
0..65535}.
-%% <KOLLA>
-%%
-%% Should we do these as maps instead?
-%% If we do we may need to include the family (domain) in the
-%% map (as the native type do. See struct sockaddr_in6).
-%%
-%% What about default values? Such as for port (=0) and addr (=any)?
-%%
-%% </KOLLA>
-
-type timeval() :: #{sec := integer(),
usec := integer()}.
@@ -183,7 +171,7 @@
addr := ip4_address() % Header Destination address
}.
-%% If the integer value is used its up to the caller to ensure its valid!
+%% If the integer value is used, its up to the caller to ensure its valid!
-type ip_tos() :: lowdeley |
throughput |
reliability |
@@ -326,10 +314,10 @@
-type otp_socket_option() :: debug |
iow |
controlling_process |
- rcvbuf |
- sndbuf |
+ rcvbuf | % sndbuf |
rcvctrlbuf |
- sndctrlbuf.
+ sndctrlbuf |
+ fd.
%% Shall we have special treatment of linger??
%% read-only options:
%% domain | protocol | type.
@@ -653,6 +641,7 @@
%%-define(SOCKET_OPT_OTP_SNDBUF, 5).
-define(SOCKET_OPT_OTP_RCVCTRLBUF, 6).
-define(SOCKET_OPT_OTP_SNDCTRLBUF, 7).
+-define(SOCKET_OPT_OTP_FD, 8).
-define(SOCKET_OPT_OTP_DOMAIN, 16#FF01). % INTERNAL
-define(SOCKET_OPT_OTP_TYPE, 16#FF02). % INTERNAL
-define(SOCKET_OPT_OTP_PROTOCOL, 16#FF03). % INTERNAL
@@ -3051,6 +3040,8 @@ enc_sockopt_key(otp, rcvctrlbuf, _, _, _, _) ->
?SOCKET_OPT_OTP_RCVCTRLBUF;
enc_sockopt_key(otp, sndctrlbuf, _, _, _, _) ->
?SOCKET_OPT_OTP_SNDCTRLBUF;
+enc_sockopt_key(otp, fd, get = _Dir, _, _, _) ->
+ ?SOCKET_OPT_OTP_FD;
enc_sockopt_key(otp = L, Opt, _, _, _, _) ->
not_supported({L, Opt});