[erlang-questions] Threads with outdated list of links

Brian Picciano mediocregopher@REDACTED
Tue Feb 19 00:50:26 CET 2013

I hope it's not bad form to post this to two places at once. I already put
this on stack overflow but I figured I might get a better response here.

I have a process that lots of threads make links to in order to associate
themselves with this process. I made the system this way so that at any
time I can easily see who is associated to the central process without
having to also keep track of any lists inside of the application itself. I
can simply do process_info(self(),links) and erlang keeps track of which
processes are still alive or not, etc....

At least, I thought so, until I found out that the list being returned on
this thread isn't accurate at this moment:

% P is my central pid
(node@REDACTED)212> P.

% Get all the links to it
(node@REDACTED)213> {links,L} = process_info(P,links).

% Counting out all the links
(node@REDACTED)214> length(L).

% Filtering out all of the dead processes, put them in Lf
(node@REDACTED)215> Lf = lists:filter(fun(Pid) -> try process_info(Pid,links)
of {links,_} -> true; _ -> false catch _:_ -> false end end, L).

% Lf is only about half the size, half the linked processes are dead!
(node@REDACTED)216> length(Lf).

% Proof that the links haven't changed in the interim
(node@REDACTED)217> {links,L} = process_info(P,links).

The only thing I can think of that would cause this is network connectivity
issues, since some of the links may come from threads on a node on another
machine. Is that a possible explanation for this? And is there a way to
make the thread clean up its link list?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130218/bb3383fe/attachment.htm>

More information about the erlang-questions mailing list