aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2014-05-01 16:31:03 +0400
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2014-05-02 17:38:47 +0400
commit16e5d66572d73839bf4ec290a5af05a25ad3a73d (patch)
tree7aeb3e157f4ba09eb0dfacc40a3aee4c69122a5d
parentMultiple REGISTER bindings support (diff)
Move some code in a separate function
-rw-r--r--src/mod_sip_registrar.erl39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/mod_sip_registrar.erl b/src/mod_sip_registrar.erl
index 48740d0ed..3e65564c1 100644
--- a/src/mod_sip_registrar.erl
+++ b/src/mod_sip_registrar.erl
@@ -168,24 +168,7 @@ handle_info({delete, US, SIPSocket, CallID, CSeq}, State) ->
delete_session(US, SIPSocket, CallID, CSeq),
{noreply, State};
handle_info({timeout, TRef, US}, State) ->
- case mnesia:dirty_read(sip_session, US) of
- [#sip_session{bindings = Bindings}] ->
- case lists:filter(
- fun(#binding{tref = TRef1}) when TRef1 == TRef ->
- false;
- (_) ->
- true
- end, Bindings) of
- [] ->
- mnesia:dirty_delete(sip_session, US);
- NewBindings ->
- mnesia:dirty_write(sip_session,
- #sip_session{us = US,
- bindings = NewBindings})
- end;
- [] ->
- ok
- end,
+ delete_expired_session(US, TRef),
{noreply, State};
handle_info(_Info, State) ->
?ERROR_MSG("got unexpected info: ~p", [_Info]),
@@ -264,6 +247,26 @@ delete_session(US, SIPSocket, CallID, CSeq) ->
{error, notfound}
end.
+delete_expired_session(US, TRef) ->
+ case mnesia:dirty_read(sip_session, US) of
+ [#sip_session{bindings = Bindings}] ->
+ case lists:filter(
+ fun(#binding{tref = TRef1}) when TRef1 == TRef ->
+ false;
+ (_) ->
+ true
+ end, Bindings) of
+ [] ->
+ mnesia:dirty_delete(sip_session, US);
+ NewBindings ->
+ mnesia:dirty_write(sip_session,
+ #sip_session{us = US,
+ bindings = NewBindings})
+ end;
+ [] ->
+ ok
+ end.
+
min_expires() ->
60.