From 944a57a11a79c5a9bb2f554c921e2e00e7d56c91 Mon Sep 17 00:00:00 2001
From: Ricardo
Date: Sat, 4 Feb 2012 16:32:21 +0100
Subject: Fix port leaking after controlling_process(Port, self())
Add case to handle the situation when someone call
{gen_tcp,gen_udp}:controlling_process(Port, self()). Also improve spec
and doc from gen_udp and gen_sctp for controlling_process/2.
To reproduce the issue, open an UDP port:
4> {ok,Port} = gen_udp:open(9000, [binary]).
{ok,#Port<0.587>}
5> gen_udp:controlling_process(Port, self()).
ok
Simulate error:
6> 1=2.
** exception error: no match of right hand side value 2
Here is the leak:
7> inet:i().
Port Module Recv Sent Owner Local Address Foreign Address State
Type
581 inet_udp 0 0 <0.31.0> *:cslistener *:* BOUND
DGRAM
ok
---
lib/kernel/doc/src/gen_tcp.xml | 2 +-
lib/kernel/doc/src/gen_udp.xml | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
(limited to 'lib/kernel/doc/src')
diff --git a/lib/kernel/doc/src/gen_tcp.xml b/lib/kernel/doc/src/gen_tcp.xml
index 8a5d40bb16..27c454afba 100644
--- a/lib/kernel/doc/src/gen_tcp.xml
+++ b/lib/kernel/doc/src/gen_tcp.xml
@@ -297,7 +297,7 @@ do_recv(Sock, Bs) ->
Socket. The controlling process is the process which
receives messages from the socket. If called by any other
process than the current controlling process,
- {error, eperm} is returned.
+ {error, not_owner} is returned.
diff --git a/lib/kernel/doc/src/gen_udp.xml b/lib/kernel/doc/src/gen_udp.xml
index daa9b7d887..9882d3fab1 100644
--- a/lib/kernel/doc/src/gen_udp.xml
+++ b/lib/kernel/doc/src/gen_udp.xml
@@ -136,7 +136,9 @@
Assigns a new controlling process Pid to
Socket. The controlling process is the process which
- receives messages from the socket.
+ receives messages from the socket. If called by any other
+ process than the current controlling process,
+ {error, not_owner} is returned.
--
cgit v1.2.3