aboutsummaryrefslogtreecommitdiff
path: root/src/mod_bosh_redis.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-07 09:10:33 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-07 09:10:33 +0300
commit3729acc5b0b60ba744540c3e5cd0ca83e9af54c4 (patch)
treeba4387b4b402c21edee8e156fc476ca374040e04 /src/mod_bosh_redis.erl
parentImprove type specs and return values (diff)
Improve logging of Redis errors
Diffstat (limited to 'src/mod_bosh_redis.erl')
-rw-r--r--src/mod_bosh_redis.erl46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/mod_bosh_redis.erl b/src/mod_bosh_redis.erl
index ca23f72bb..156df368b 100644
--- a/src/mod_bosh_redis.erl
+++ b/src/mod_bosh_redis.erl
@@ -28,18 +28,13 @@ open_session(SID, Pid) ->
case ejabberd_redis:hset(?BOSH_KEY, SID, PidBin) of
{ok, _} ->
ok;
- Err ->
- ?ERROR_MSG("failed to register bosh session in redis: ~p", [Err]),
- Err
+ {error, _} ->
+ {error, db_failure}
end.
close_session(SID) ->
- case ejabberd_redis:hdel(?BOSH_KEY, [SID]) of
- {ok, _} ->
- ok;
- Err ->
- ?ERROR_MSG("failed to delete bosh session in redis: ~p", [Err])
- end.
+ ejabberd_redis:hdel(?BOSH_KEY, [SID]),
+ ok.
find_session(SID) ->
case ejabberd_redis:hget(?BOSH_KEY, SID) of
@@ -51,10 +46,7 @@ find_session(SID) ->
[SID, Pid]),
error
end;
- {ok, _} ->
- error;
- Err ->
- ?ERROR_MSG("failed to lookup bosh session in redis: ~p", [Err]),
+ _ ->
error
end.
@@ -65,20 +57,16 @@ clean_table() ->
?INFO_MSG("Cleaning Redis BOSH sessions...", []),
case ejabberd_redis:hgetall(?BOSH_KEY) of
{ok, Vals} ->
- case ejabberd_redis:multi(
- fun() ->
- lists:foreach(
- fun({SID, Pid}) when node(Pid) == node() ->
- ejabberd_redis:hdel(?BOSH_KEY, [SID]);
- (_) ->
- ok
- end, Vals)
- end) of
- {ok, _} ->
- ok;
- Err ->
- ?ERROR_MSG("failed to clean bosh sessions in redis: ~p", [Err])
- end;
- Err ->
- ?ERROR_MSG("failed to clean bosh sessions in redis: ~p", [Err])
+ ejabberd_redis:multi(
+ fun() ->
+ lists:foreach(
+ fun({SID, Pid}) when node(Pid) == node() ->
+ ejabberd_redis:hdel(?BOSH_KEY, [SID]);
+ (_) ->
+ ok
+ end, Vals)
+ end),
+ ok;
+ {error, _} ->
+ ?ERROR_MSG("failed to clean bosh sessions in redis", [])
end.