]> granicus.if.org Git - ejabberd/commitdiff
Don't crash on most common gen_server:call errors
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sun, 1 Jul 2018 11:26:49 +0000 (14:26 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sun, 1 Jul 2018 11:26:49 +0000 (14:26 +0300)
src/ejabberd_sql.erl
src/mod_stream_mgmt.erl

index 28103430a89ac7bab26fc26f60af2817537705d0..970dece3fac07dc10ecae0fe128164d25a8516b7 100644 (file)
@@ -580,8 +580,13 @@ sql_query_internal(#sql_query{} = Query) ->
                 sqlite ->
                     sqlite_sql_query(Query)
             end
-        catch
-            Class:Reason ->
+        catch exit:{timeout, _} ->
+               {error, <<"timed out">>};
+             exit:{killed, _} ->
+               {error, <<"killed">>};
+             exit:{normal, _} ->
+               {error, <<"terminated unexpectedly">>};
+             Class:Reason ->
                 ST = erlang:get_stacktrace(),
                 ?ERROR_MSG("Internal error while processing SQL query: ~p",
                            [{Class, Reason, ST}]),
index 62124b22e8a7c210e94abfab8579594b960d96da..6fb601817baa83a44529b70e9e86eaf7427c856d 100644 (file)
@@ -682,6 +682,8 @@ inherit_session_state(#{user := U, server := S,
                            {error, <<"Previous session PID is dead">>};
                          exit:{normal, _} ->
                            {error, <<"Previous session PID has exited">>};
+                         exit:{killed, _} ->
+                           {error, <<"Previous session PID has been killed">>};
                          exit:{timeout, _} ->
                            ejabberd_sm:close_session(OldSID, U, S, R),
                            ejabberd_c2s:stop(OldPID),