aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_riak.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ejabberd_riak.erl')
-rw-r--r--src/ejabberd_riak.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ejabberd_riak.erl b/src/ejabberd_riak.erl
index a86ac06d3..5bf783612 100644
--- a/src/ejabberd_riak.erl
+++ b/src/ejabberd_riak.erl
@@ -181,7 +181,7 @@ get(Table, RecSchema, Key) ->
-spec get_by_index(atom(), record_schema(), binary(), any()) ->
{ok, [any()]} | {error, any()}.
-%% @doc Reads records by `Index' and value `Key' from `Table'
+%% @doc Reads records by `Index' and value `Key' from `Table'
get_by_index(Table, RecSchema, Index, Key) ->
{NewIndex, NewKey} = encode_index_key(Index, Key),
case get_by_index_raw(Table, NewIndex, NewKey) of
@@ -459,7 +459,7 @@ handle_cast(_Msg, State) ->
handle_info({'DOWN', _MonitorRef, _Type, _Object, _Info}, State) ->
{stop, normal, State};
handle_info(_Info, State) ->
- ?ERROR_MSG("unexpected info: ~p", [_Info]),
+ ?ERROR_MSG("Unexpected info: ~p", [_Info]),
{noreply, State}.
%% @private
@@ -511,7 +511,7 @@ log_error({error, Why} = Err, Function, Opts) ->
true ->
io_lib:fwrite("** Error: ~p", [Err])
end,
- ?ERROR_MSG("database error:~n** Function: ~p~n~s~s",
+ ?ERROR_MSG("Database error:~n** Function: ~p~n~s~s",
[Function, Txt, ErrTxt]);
log_error(_, _, _) ->
ok.
@@ -520,8 +520,13 @@ make_invalid_object(Val) ->
(str:format("Invalid object: ~p", [Val])).
get_random_pid() ->
- PoolPid = ejabberd_riak_sup:get_random_pid(),
- get_riak_pid(PoolPid).
+ case ejabberd_riak_sup:start() of
+ ok ->
+ PoolPid = ejabberd_riak_sup:get_random_pid(),
+ get_riak_pid(PoolPid);
+ {error, _} = Err ->
+ Err
+ end.
get_riak_pid(PoolPid) ->
case catch gen_server:call(PoolPid, get_pid) of