[erlang-questions] pg2 still busted in R13B04

Evans, Matthew mevans@REDACTED
Tue May 25 22:52:21 CEST 2010


If you are feeling brave edit pg2.erl and change the ets:update_counter(pg2_table...) calls in join_group and leave_group as shown below:

join_group:
    try _ = ets:update_counter(pg2_table, Member_Name_Pid, {2, +1, 1, 1})

leave_group:
    try ets:update_counter(pg2_table, Member_Name_Pid, {2, -1, 0, 0}) of

It's not a permanent solution, but it works:

i.e:

join_group(Name, Pid) ->
    Ref_Pid = {ref, Pid},
    try _ = ets:update_counter(pg2_table, Ref_Pid, {4, +1})
    catch _:_ ->
            {RPid, Ref} = do_monitor(Pid),
            true = ets:insert(pg2_table, {Ref_Pid, RPid, Ref, 1}),
            true = ets:insert(pg2_table, {{ref, Ref}, Pid})
    end,
    Member_Name_Pid = {member, Name, Pid},
    try _ = ets:update_counter(pg2_table, Member_Name_Pid, {2, +1, 1, 1})
    catch _:_ ->
            true = ets:insert(pg2_table, {Member_Name_Pid, 1}),
            _ = [ets:insert(pg2_table, {{local_member, Name, Pid}}) ||
                    node(Pid) =:= node()],
            true = ets:insert(pg2_table, {{pid, Pid, Name}})
    end.

leave_group(Name, Pid) ->
    Member_Name_Pid = {member, Name, Pid},
    try ets:update_counter(pg2_table, Member_Name_Pid, {2, -1, 0, 0}) of
        N ->
            if
                N =:= 0 ->
                    true = ets:delete(pg2_table, {pid, Pid, Name}),
                    _ = [ets:delete(pg2_table, {local_member, Name, Pid}) ||
                            node(Pid) =:= node()],
                    true = ets:delete(pg2_table, Member_Name_Pid);
                true ->
                    ok
            end,
            Ref_Pid = {ref, Pid},
            case ets:update_counter(pg2_table, Ref_Pid, {4, -1}) of
                0 ->
                    [{Ref_Pid,RPid,Ref,0}] = ets:lookup(pg2_table, Ref_Pid),
                    true = ets:delete(pg2_table, {ref, Ref}),
                    true = ets:delete(pg2_table, Ref_Pid),
                    true = erlang:demonitor(Ref, [flush]),
                    kill_monitor_proc(RPid, Pid);
                _ ->
                    ok
            end
    catch _:_ ->
            ok
    end.

-----Original Message-----
From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of Rick Pettit
Sent: Tuesday, May 25, 2010 4:40 PM
To: Jesper Louis Andersen
Cc: erlang-questions@REDACTED
Subject: Re: [erlang-questions] pg2 still busted in R13B04

On Tue, May 25, 2010 3:22 pm, Jesper Louis Andersen wrote:
> On Tue, May 25, 2010 at 9:46 PM, Rick Pettit <rpettit@REDACTED> wrote:
>> A while ago someone had posted that pg2 appeared to be broken as of
>> R13B03.
>>
>> I am doing some testing with R13B04, and am finding the same to be true.
>
> If you have a failing test case, then by all means make it available
> to the Erlang developers. That way, it is many times easier to fix
> eventual problems.

I'm working on it, but in the meantime the following bug report appears to
cover the problem I'm having:

  http://permalink.gmane.org/gmane.comp.lang.erlang.bugs/1838

-Rick

> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>



________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED



More information about the erlang-questions mailing list