Socket owner changing code in inet_tcp.erl

Scott Lystig Fritchie scott@REDACTED
Fri Apr 7 19:15:44 CEST 2000

I've got a quick question about kernel-2.5's version of inet_tcp.erl:

	owner(Tcp, Owner, LIX, St, NewOwner) ->
	        {commit_owner, NewOwner} ->
	            Owner ! {owner, NewOwner},
	            listen_loop(Tcp, NewOwner, LIX, St);
	        {abort_owner, NewOwner} ->
	            listen_loop(Tcp, Owner, LIX, St)

Why is the unlink() done before the link()?  I would expect the link()
to be done first, to be paranoid about avoiding detached processes.

If Owner dies, it's an honest race to see if the unlink() happens
before that fact is propagated to the socket process.  If NewOwner
dies before the link(), then the link() should send an 'EXIT' signal
to the socket process.  Hm.  I suppose that's OK.

Come to think of it ... perhaps it's done this way to avoid the tiny
window of opportunity where the socket process is linked to both Owner
and NewOwner, and the death of NewOwner would also kill Owner, and
that would be a bad thing?


More information about the erlang-questions mailing list