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

Don't crash on most common gen_server:call errors

This commit is contained in:
Evgeniy Khramtsov 2018-07-01 14:26:49 +03:00
parent b662ec2a78
commit 6b8bc811ac
2 changed files with 9 additions and 2 deletions

View File

@ -580,8 +580,13 @@ sql_query_internal(#sql_query{} = Query) ->
sqlite -> sqlite ->
sqlite_sql_query(Query) sqlite_sql_query(Query)
end end
catch catch exit:{timeout, _} ->
Class:Reason -> {error, <<"timed out">>};
exit:{killed, _} ->
{error, <<"killed">>};
exit:{normal, _} ->
{error, <<"terminated unexpectedly">>};
Class:Reason ->
ST = erlang:get_stacktrace(), ST = erlang:get_stacktrace(),
?ERROR_MSG("Internal error while processing SQL query: ~p", ?ERROR_MSG("Internal error while processing SQL query: ~p",
[{Class, Reason, ST}]), [{Class, Reason, ST}]),

View File

@ -682,6 +682,8 @@ inherit_session_state(#{user := U, server := S,
{error, <<"Previous session PID is dead">>}; {error, <<"Previous session PID is dead">>};
exit:{normal, _} -> exit:{normal, _} ->
{error, <<"Previous session PID has exited">>}; {error, <<"Previous session PID has exited">>};
exit:{killed, _} ->
{error, <<"Previous session PID has been killed">>};
exit:{timeout, _} -> exit:{timeout, _} ->
ejabberd_sm:close_session(OldSID, U, S, R), ejabberd_sm:close_session(OldSID, U, S, R),
ejabberd_c2s:stop(OldPID), ejabberd_c2s:stop(OldPID),