Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xela85 committed Aug 22, 2024
1 parent c02fa07 commit 6641a31
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/ejabberd.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/rebar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/sbt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/scala_compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added conf/ejabberd.yml
Empty file.
6 changes: 5 additions & 1 deletion src/ejabberd_sm_sql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ init() ->
case ejabberd_sql:sql_query(
Host, ?SQL("delete from sm where node=%(Node)s")) of
{updated, _} ->
?DEBUG("Successfully cleaned 'sm' table on host: ~p", [Host]),
ok;
Err ->
?DEBUG("Error tatata", []),
?ERROR_MSG("Failed to clean 'sm' table: ~p", [Err]),
{error, db_failure}
end;
(_, Err) ->
?DEBUG("Another case...", []),
Err
end, ok, ejabberd_sm:get_vh_by_backend(?MODULE)).
end, ok, ejabberd_sm:get_vh_by_backend(?MODULE)),
?DEBUG("Bullshit done...", []).

schemas() ->
[#sql_schema{
Expand Down
6 changes: 6 additions & 0 deletions src/ejabberd_sql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ sql_call(Host, Msg) ->
Timeout = query_timeout(Host),
case get(?STATE_KEY) of
undefined ->
?DEBUG("No existing state", []),
sync_send_event(Host,
{sql_cmd, Msg, current_time() + Timeout},
Timeout);
_State ->
?DEBUG("Existing state", [_State]),
nested_op(Msg)
end.

Expand All @@ -167,14 +169,18 @@ keep_alive(Host, Proc) ->
sync_send_event(Host, Msg, Timeout) when is_binary(Host) ->
case ejabberd_sql_sup:start(Host) of
ok ->
?DEBUG("Loaded sql sup", []),
Proc = get_worker(Host),
sync_send_event(Proc, Msg, Timeout);
{error, _} = Err ->
?DEBUG("Error while starting sql sup", []),
Err
end;
sync_send_event(Proc, Msg, Timeout) ->
?DEBUG("sync_send_event 180", []),
try p1_fsm:sync_send_event(Proc, Msg, Timeout)
catch _:{Reason, {p1_fsm, _, _}} ->
?DEBUG("sync_send_event 180 error", []),
{error, Reason}
end.

Expand Down
2 changes: 2 additions & 0 deletions src/ejabberd_sql_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
start(Host) ->
case should_update_schema(Host) of
true ->
?DEBUG("Should update schema", []),
case table_exists(Host, <<"schema_version">>) of
true ->
ok;
Expand All @@ -52,6 +53,7 @@ start(Host) ->
end
end;
false ->
?DEBUG("Should not update schema", []),
ok
end.

Expand Down

0 comments on commit 6641a31

Please sign in to comment.