aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/inet.erl
diff options
context:
space:
mode:
authorHolger Weiß <[email protected]>2015-04-09 21:24:32 +0200
committerHolger Weiß <[email protected]>2015-04-09 21:24:32 +0200
commitc1780b76cdfefbb52025afcf27f6eab01a464e90 (patch)
tree141d5c19cbd9250fcf6ab432b51ff8cb2f53e87c /lib/kernel/src/inet.erl
parent545890576542e4be630df8772654b99bd0306f62 (diff)
downloadotp-c1780b76cdfefbb52025afcf27f6eab01a464e90.tar.gz
otp-c1780b76cdfefbb52025afcf27f6eab01a464e90.tar.bz2
otp-c1780b76cdfefbb52025afcf27f6eab01a464e90.zip
Don't throw exception on prim_inet:setopt/3 error
Let gen_tcp:controlling_process/2 and inet_sctp:connect/[45] propagate prim_inet:setopt/3 errors instead of having them generate badmatch exceptions.
Diffstat (limited to 'lib/kernel/src/inet.erl')
-rw-r--r--lib/kernel/src/inet.erl24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl
index ec2c350931..d668738109 100644
--- a/lib/kernel/src/inet.erl
+++ b/lib/kernel/src/inet.erl
@@ -1527,26 +1527,28 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
_ ->
case prim_inet:getopt(S, active) of
{ok, A0} ->
- case A0 of
- false -> ok;
- _ -> ok = prim_inet:setopt(S, active, false)
- end,
- case tcp_sync_input(S, NewOwner, false) of
- true -> %% socket already closed,
+ SetOptRes =
+ case A0 of
+ false -> ok;
+ _ -> prim_inet:setopt(S, active, false)
+ end,
+ case {tcp_sync_input(S, NewOwner, false), SetOptRes} of
+ {true, _} -> %% socket already closed
ok;
- false ->
+ {false, ok} ->
try erlang:port_connect(S, NewOwner) of
true ->
unlink(S), %% unlink from port
case A0 of
false -> ok;
- _ -> ok = prim_inet:setopt(S, active, A0)
- end,
- ok
+ _ -> prim_inet:setopt(S, active, A0)
+ end
catch
error:Reason ->
{error, Reason}
- end
+ end;
+ {false, Error} ->
+ Error
end;
Error ->
Error