25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Move some code in a separate function

This commit is contained in:
Evgeniy Khramtsov 2014-05-01 16:31:03 +04:00
parent 6a95422af8
commit 16e5d66572

View File

@ -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.