fixeria submitted this change.

View Change

Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
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(-)

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),

To view, visit change 42296. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I4cb044e8071c4ae2fc48c507f8733af6c617ec46
Gerrit-Change-Number: 42296
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>