aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2014-07-24 17:04:46 +0200
committerHenrik Nord <[email protected]>2014-07-24 17:09:03 +0200
commit7de69a943ebf3be3fc9b8b4f79bba2819107e1ab (patch)
tree3bd523f78022cf457c41da02999abf0029b47f60 /lib/kernel/src
parent6cae32f48905328561f28fe9eed1a4f18bbf1bd0 (diff)
parent1b9383a8dbc03473860dfaacc7a02fbc8b1b1185 (diff)
downloadotp-7de69a943ebf3be3fc9b8b4f79bba2819107e1ab.tar.gz
otp-7de69a943ebf3be3fc9b8b4f79bba2819107e1ab.tar.bz2
otp-7de69a943ebf3be3fc9b8b4f79bba2819107e1ab.zip
Merge branch 'maint'
Conflicts: erts/preloaded/ebin/prim_inet.beam
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/inet.erl33
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl
index 41d422d7d4..d17da2d329 100644
--- a/lib/kernel/src/inet.erl
+++ b/lib/kernel/src/inet.erl
@@ -1257,9 +1257,9 @@ open(FdO, Addr, Port, Opts, Protocol, Family, Type, Module)
Error ->
Error
end;
-open(Fd, _Addr, _Port, Opts, Protocol, Family, Type, Module)
+open(Fd, Addr, Port, Opts, Protocol, Family, Type, Module)
when is_integer(Fd) ->
- fdopen(Fd, Opts, Protocol, Family, Type, Module).
+ fdopen(Fd, Addr, Port, Opts, Protocol, Family, Type, Module).
bindx(S, [Addr], Port0) ->
{IP, Port} = set_bindx_port(Addr, Port0),
@@ -1298,12 +1298,35 @@ change_bindx_0_port({_IP, _Port}=Addr, _AssignedPort) ->
{'ok', socket()} | {'error', posix()}.
fdopen(Fd, Opts, Protocol, Family, Type, Module) ->
- case prim_inet:fdopen(Protocol, Family, Type, Fd) of
+ fdopen(Fd, any, 0, Opts, Protocol, Family, Type, Module).
+
+fdopen(Fd, Addr, Port, Opts, Protocol, Family, Type, Module) ->
+ IsAnyAddr = (Addr == {0,0,0,0} orelse Addr == {0,0,0,0,0,0,0,0}
+ orelse Addr == any),
+ Bound = Port == 0 andalso IsAnyAddr,
+ case prim_inet:fdopen(Protocol, Family, Type, Fd, Bound) of
{ok, S} ->
case prim_inet:setopts(S, Opts) of
ok ->
- inet_db:register_socket(S, Module),
- {ok, S};
+ case if
+ Bound ->
+ %% We do not do any binding if default
+ %% port+addr options where given in order
+ %% to keep backwards compatability with
+ %% pre Erlang/TOP 17
+ {ok, ok};
+ is_list(Addr) ->
+ bindx(S, Addr, Port);
+ true ->
+ prim_inet:bind(S, Addr, Port)
+ end of
+ {ok, _} ->
+ inet_db:register_socket(S, Module),
+ {ok, S};
+ Error ->
+ prim_inet:close(S),
+ Error
+ end;
Error ->
prim_inet:close(S), Error
end;