Make rabbit_mochiweb_registry:add/4 overwrite a record if you add the same context twice, rather than insert a duplicate.

This commit is contained in:
Simon MacMullen 2011-07-07 13:01:52 +01:00
parent c7a144db03
commit 84ba37b6c8
1 changed files with 3 additions and 1 deletions

View File

@ -50,7 +50,9 @@ handle_call({add, Context, Selector, Handler, Link}, _From,
rabbit_mochiweb:context_listener(Context),
rabbit_mochiweb_sup:ensure_listener(ListenerSpec),
case lookup_dispatch(Listener) of
{Selectors, Fallback} ->
{OldSelectors, Fallback} ->
Selectors = lists:filter(fun ({C, _, _, _}) -> C =/= Context end,
OldSelectors),
set_dispatch(Listener,
{Selectors ++ [{Context, Selector, Handler, Link}],
Fallback}),