fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42296?usp=email )
Change subject: enb_registry: fix pattern match in handle_info 'DOWN' handler ......................................................................
enb_registry: fix pattern match in handle_info 'DOWN' handler
PIDs maps pid() => enb_handle() (an integer), so maps:find/2 returns {ok, SomeHandle}. The old pattern {ok, Pid} tried to match an integer against the already-bound pid() variable, which never succeeds.
This handler is only called on abnormal termination (process crash), so the broken match caused the registry entry to never be cleaned up in that case. Fix by using a fresh {ok, Handle} binding and removing the now-redundant follow-up maps:get/2 call.
Change-Id: I4cb044e8071c4ae2fc48c507f8733af6c617ec46 --- M src/enb_registry.erl 1 file changed, 1 insertion(+), 2 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/enb_registry.erl b/src/enb_registry.erl index 54eca5d..d2487a0 100644 --- a/src/enb_registry.erl +++ b/src/enb_registry.erl @@ -257,8 +257,7 @@ pids = PIDs} = S) -> ?LOG_INFO("eNB process (pid=~p) terminated with reason ~p", [Pid, Reason]), case maps:find(Pid, PIDs) of - {ok, Pid} -> - Handle = maps:get(Pid, PIDs), + {ok, Handle} -> enb_metrics_reset(maps:get(Handle, ENBs)), ?LOG_INFO("eNB (handle=~p, pid=~p) has been unregistered", [Handle, Pid]), {noreply, S#state{enbs = maps:remove(Handle, ENBs),