sccp_{links,user}: Add EXIT info handler for ets table cleanup

Once a linked process dies, we evict all related records from our ETS
tables.
This commit is contained in:
Harald Welte 2011-05-01 14:23:05 +02:00
parent d975d90fcc
commit 49fb161451
2 changed files with 13 additions and 0 deletions

View File

@ -170,6 +170,13 @@ handle_cast(Info, S) ->
{info, Info}, {state, S}]),
{noreply, S}.
handle_info({'EXIT', Pid, Reason}, S) ->
io:format("EXIT from Process ~p (~p), cleaning up tables~n",
[Pid, Reason]),
#su_state{linkset_tbl = LinksetTbl, link_tbl = LinkTbl} = S,
ets:match_delete(LinksetTbl, #slinkset{user_pid = Pid}),
ets:match_delete(LinkTbl, #slink{user_pid = Pid}),
{noreply, S};
handle_info(Info, S) ->
error_logger:error_report(["unknown handle_info",
{module, ?MODULE},

View File

@ -110,6 +110,12 @@ handle_cast(Info, S) ->
{info, Info}, {state, S}]),
{noreply, S}.
handle_info({'EXIT', Pid, Reason}, S) ->
#scu_state{user_table = Tbl} = S,
io:format("EXIT from Process ~p (~p), cleaning up tables~n",
[Pid, Reason]),
ets:match_delete(Tbl, #scu_record{user_pid = Pid}),
{noreply, S};
handle_info(Info, S) ->
error_logger:error_report(["unknown handle_info",
{module, ?MODULE},