fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42297?usp=email )


Change subject: enb_registry: fix duplicate registration check in enb_register/0
......................................................................

enb_registry: fix duplicate registration check in enb_register/0

next_handle was bound in the function head and reused in the case
pattern {ok, Handle}, turning what looks like a binding into an
equality test against next_handle.  The duplicate check therefore
only fired if the previously assigned handle happened to equal the
current next_handle counter, which is essentially never true.

Fix by removing next_handle from the function head pattern and reading
it with S#state.next_handle inside the error branch, so that Handle in
{ok, Handle} is always a fresh binding that matches any existing handle.

Change-Id: Ia64f3e2e79bea055e5c37df9bce91a4bcbf7184c
---
M src/enb_registry.erl
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw 
refs/changes/97/42297/1

diff --git a/src/enb_registry.erl b/src/enb_registry.erl
index d2487a0..29a2575 100644
--- a/src/enb_registry.erl
+++ b/src/enb_registry.erl
@@ -155,13 +155,13 @@
 handle_call(enb_register,
             {Pid, _Tag},
             #state{enbs = ENBs,
-                   pids = PIDs,
-                   next_handle = Handle} = S) ->
+                   pids = PIDs} = S) ->
     case maps:find(Pid, PIDs) of
         {ok, Handle} ->
             ?LOG_ERROR("eNB (handle=~p, pid=~p) is *already* registered", 
[Handle, Pid]),
             {reply, {error, already_registered}, S};
         error ->
+            Handle = S#state.next_handle,
             %% keep an eye on the process being registered
             MonRef = erlang:monitor(process, Pid),
             %% create and store an initial eNB state

--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42297?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: Ia64f3e2e79bea055e5c37df9bce91a4bcbf7184c
Gerrit-Change-Number: 42297
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>

Reply via email to