ostinelli / syn

A scalable global Process Registry and Process Group manager for Erlang and Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pid registered on more than one Group is not removed from them when is killed

vitor-moymer opened this issue · comments

on syn_groups just the case of a process being in one group is handled when a process receive Exit signal

handle_info({'EXIT', Pid, Reason}, State) ->
    %% check if pid is in table
    case i_find_by_pid(Pid) of
        undefined ->
            %% log
            case Reason of
                normal -> ok;
                killed -> ok;
                _ ->
                    error_logger:error_msg("Received an exit message from an unlinked process ~p with reason: ~p", [Pid, Reason])
            end;

        Process ->
            %% get group
            Name = Process#syn_groups_table.name,
            %% log
            case Reason of
                normal -> ok;
                killed -> ok;
                _ ->
                    error_logger:error_msg("Process of group ~p and pid ~p exited with reason: ~p", [Name, Pid, Reason])
            end,
            %% delete from table
            remove_process(Process)
    end,

#######

i_find_by_pid(Pid) ->
    case mnesia:dirty_index_read(syn_groups_table, Pid, #syn_groups_table.pid) of
        [Process] -> Process;
        _ -> undefined
    end.

Thank you. Fixed and released in 1.4.0.