[erlang-questions] gen_udp port leaking after controlling_process(Port, self())

Tony Rogvall tony@REDACTED
Wed Apr 27 19:36:39 CEST 2011


Nice ! ;-)

Same problem with gen_tcp ! 
You can use inet:i() to verify that even Erlang knows about the problem :-)

I see the problem.  inet:udp/tcp_controlling_process unlinks from the socket without 
checking that it is already the controlling process, effectively creating a zombie port.

Work around: Do not change the controlling process to it self.

/Tony


On 27 apr 2011, at 19.05, Max Lapshin wrote:

> Open UDP port
> 
> $ erl
> Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:4:4] [rq:4]
> [async-threads:0] [hipe] [kernel-poll:false]
> 
> Eshell V5.8.3  (abort with ^G)
> 1> {ok,Port} = gen_udp:open(9000, [binary]).
> {ok,#Port<0.576>}
> 
> $ lsof -nP -i|grep beam|grep UDP
> beam.smp  10912  max   11u  IPv4 0x089073c4      0t0  UDP *:9000
> 
> 
> 
> Simulate error:
> 2> a=b.
> ** exception error: no match of right hand side value b
> 
> All ports are closed.
> 
> $ lsof -nP -i|grep beam|grep UDP
> $
> 
> 
> Now add controlling_process:
> 
> 4> {ok,Port} = gen_udp:open(9000, [binary]).
> {ok,#Port<0.587>}
> 5> gen_udp:controlling_process(Port, self()).
> ok
> 6> a=b.
> ** exception error: no match of right hand side value b
> 
> Voila: port is not closed
> 
> lsof -nP -i|grep beam|grep UDP
> beam.smp  10912  max   11u  IPv4 0x089073c4      0t0  UDP *:9000
> 
> 
> Where is it? To which process belongs it now and when will it be closed?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

"Have run Make so many times I dunno what's installed anymore"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110427/13d24a32/attachment.htm>


More information about the erlang-questions mailing list