diff options
author | Henrik Nord <[email protected]> | 2015-06-02 14:38:52 +0200 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2015-06-02 14:41:45 +0200 |
commit | 00872fbaa648c47f49adf221656b186810ccfc9d (patch) | |
tree | 7514de0f92d502b943317f6fc94966eea2136908 /lib/kernel/src/inet.erl | |
parent | 2d4367f3c863e71006aed3e0076cf3cd08ca2b42 (diff) | |
parent | c1780b76cdfefbb52025afcf27f6eab01a464e90 (diff) | |
download | otp-00872fbaa648c47f49adf221656b186810ccfc9d.tar.gz otp-00872fbaa648c47f49adf221656b186810ccfc9d.tar.bz2 otp-00872fbaa648c47f49adf221656b186810ccfc9d.zip |
Merge branch 'weiss/propagate-setopt-error'
* weiss/propagate-setopt-error:
Don't throw exception on prim_inet:setopt/3 error
OTP-12798
Diffstat (limited to 'lib/kernel/src/inet.erl')
-rw-r--r-- | lib/kernel/src/inet.erl | 24 |
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 |