aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-09-18 12:40:43 +0200
committerMicael Karlberg <[email protected]>2018-09-18 14:50:18 +0200
commitd72a3c72dc6e74fb06e4e488db32fc819ce0c088 (patch)
tree8e9f8f35120a6a70b743f412b34fff0576a50319
parent93ed18d0b5e46c9637ff50052e1d12a66d5d40e1 (diff)
downloadotp-d72a3c72dc6e74fb06e4e488db32fc819ce0c088.tar.gz
otp-d72a3c72dc6e74fb06e4e488db32fc819ce0c088.tar.bz2
otp-d72a3c72dc6e74fb06e4e488db32fc819ce0c088.zip
[socket-nif] Cleanup and guards
Some cleanup and also added a guard to sendmsg to ensure that only ctrl (cmsg hdr) with actual content will be "sent down". OTP-14831
-rw-r--r--erts/preloaded/ebin/socket.beambin66000 -> 66132 bytes
-rw-r--r--erts/preloaded/src/socket.erl19
2 files changed, 2 insertions, 17 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index b3f3e385d2..1100065e2a 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 d1053d88f9..ad7a35694b 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -565,20 +565,6 @@
credentials |
origdstaddr |
integer().
-%% Do we need this? See cmsghdr()
-%% -type cmsghdr_data() :: timeval() | % if level = socket and type = timstamp
-%% ip_pktinfo() | % if level = ip and type = pktinfo
-%% ipv6_pktinfo() | % if level = ipv6 and type = pktinfo
-%% ip_tos() | % if level = ip and type = tos
-%% integer() | % if level = ip and type = ttl
-%% sockaddr_in4() | % if level = ip and type = origdstaddr
-%% binary().
-%% -type cmsghdr() :: #{
-%% level := cmsghdr_level(),
-%% type := cmsghdr_type(),
-%% data := cmsghdr_data()
-%% }.
-
-type cmsghdr_recv() ::
#{level := socket, type := timestamp, data := timeval()} |
#{level := socket, type := rights, data := binary()} |
@@ -592,8 +578,6 @@
#{level := ipv6, type := pktinfo, data := ipv6_pktinfo()} |
#{level := ipv6, type := integer(), data := binary()} |
#{level := integer(), type := integer(), data := binary()}.
-
-
-type cmsghdr_send() ::
#{level := socket, type := integer(), data := binary()} |
#{level := ip, type := tos, data := ip_tos() | binary()} |
@@ -1522,9 +1506,10 @@ do_sendmsg(SockRef, MsgHdr, EFlags, Timeout) ->
ERROR
end.
+ensure_msghdr(#{ctrl := []} = M) ->
+ ensure_msghdr(maps:remove(ctrl, M));
ensure_msghdr(#{iov := IOV} = M) when is_list(IOV) andalso (IOV =/= []) ->
M#{iov := erlang:iolist_to_iovec(IOV)};
- %% M;
ensure_msghdr(_) ->
einval().