diff options
author | Lukas Larsson <[email protected]> | 2012-05-23 11:25:08 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2012-05-23 11:25:08 +0200 |
commit | 90cbd16d39bb00c6eb4f3ffe04a406f800ee9126 (patch) | |
tree | 8b5c7b186208b84797ec9b614443c802392133ae /lib/kernel/src | |
parent | 0d98106bfa6f0c637019604f4c25e6c48cd1d5fc (diff) | |
parent | 1ba2039020738673b3913be0e48d83713503a3b7 (diff) | |
download | otp-90cbd16d39bb00c6eb4f3ffe04a406f800ee9126.tar.gz otp-90cbd16d39bb00c6eb4f3ffe04a406f800ee9126.tar.bz2 otp-90cbd16d39bb00c6eb4f3ffe04a406f800ee9126.zip |
Merge branch 'maint'
* maint:
Add testcase for controlling_process(P,self())
Fix port leaking after controlling_process(Port, self())
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/gen_sctp.erl | 5 | ||||
-rw-r--r-- | lib/kernel/src/gen_udp.erl | 5 | ||||
-rw-r--r-- | lib/kernel/src/inet.erl | 4 |
3 files changed, 10 insertions, 4 deletions
diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl index d8954f0cf7..8fa963ec78 100644 --- a/lib/kernel/src/gen_sctp.erl +++ b/lib/kernel/src/gen_sctp.erl @@ -425,9 +425,10 @@ error_string(X) -> erlang:error(badarg, [X]). --spec controlling_process(Socket, Pid) -> ok when +-spec controlling_process(Socket, Pid) -> ok | {error, Reason} when Socket :: sctp_socket(), - Pid :: pid(). + Pid :: pid(), + Reason :: closed | not_owner | inet:posix(). controlling_process(S, Pid) when is_port(S), is_pid(Pid) -> inet:udp_controlling_process(S, Pid); diff --git a/lib/kernel/src/gen_udp.erl b/lib/kernel/src/gen_udp.erl index 8688799ae9..914854c65c 100644 --- a/lib/kernel/src/gen_udp.erl +++ b/lib/kernel/src/gen_udp.erl @@ -185,9 +185,10 @@ connect(S, Address, Port) when is_port(S) -> Error end. --spec controlling_process(Socket, Pid) -> ok when +-spec controlling_process(Socket, Pid) -> ok | {error, Reason} when Socket :: socket(), - Pid :: pid(). + Pid :: pid(), + Reason :: closed | not_owner | inet:posix(). controlling_process(S, NewOwner) -> inet:udp_controlling_process(S, NewOwner). diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl index b0a955fdcc..a651e82122 100644 --- a/lib/kernel/src/inet.erl +++ b/lib/kernel/src/inet.erl @@ -1246,6 +1246,8 @@ udp_close(S) when is_port(S) -> %% Set controlling process for TCP socket. tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) -> case erlang:port_info(S, connected) of + {connected, NewOwner} -> + ok; {connected, Pid} when Pid =/= self() -> {error, not_owner}; undefined -> @@ -1297,6 +1299,8 @@ tcp_sync_input(S, Owner, Flag) -> %% Set controlling process for UDP or SCTP socket. udp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) -> case erlang:port_info(S, connected) of + {connected, NewOwner} -> + ok; {connected, Pid} when Pid =/= self() -> {error, not_owner}; _ -> |