Move some code in a separate function
This commit is contained in:
parent
6a95422af8
commit
16e5d66572
|
@ -168,24 +168,7 @@ handle_info({delete, US, SIPSocket, CallID, CSeq}, State) ->
|
||||||
delete_session(US, SIPSocket, CallID, CSeq),
|
delete_session(US, SIPSocket, CallID, CSeq),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info({timeout, TRef, US}, State) ->
|
handle_info({timeout, TRef, US}, State) ->
|
||||||
case mnesia:dirty_read(sip_session, US) of
|
delete_expired_session(US, TRef),
|
||||||
[#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,
|
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info(_Info, State) ->
|
handle_info(_Info, State) ->
|
||||||
?ERROR_MSG("got unexpected info: ~p", [_Info]),
|
?ERROR_MSG("got unexpected info: ~p", [_Info]),
|
||||||
|
@ -264,6 +247,26 @@ delete_session(US, SIPSocket, CallID, CSeq) ->
|
||||||
{error, notfound}
|
{error, notfound}
|
||||||
end.
|
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() ->
|
min_expires() ->
|
||||||
60.
|
60.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue