25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Set 'sql_pool_size' to 1 by default for sqlite

This commit is contained in:
Evgeniy Khramtsov 2016-11-21 21:34:56 +03:00
parent 3908a80ac9
commit 3189bb3bb9

View File

@ -61,10 +61,6 @@ start_link(Host) ->
?MODULE, [Host]).
init([Host]) ->
PoolSize = ejabberd_config:get_option(
{sql_pool_size, Host},
fun(I) when is_integer(I), I>0 -> I end,
?DEFAULT_POOL_SIZE),
StartInterval = ejabberd_config:get_option(
{sql_start_interval, Host},
fun(I) when is_integer(I), I>0 -> I end,
@ -76,6 +72,7 @@ init([Host]) ->
(mssql) -> mssql;
(odbc) -> odbc
end, odbc),
PoolSize = get_pool_size(Type, Host),
case Type of
sqlite ->
check_sqlite_db(Host);
@ -117,6 +114,23 @@ remove_pid(Host, Pid) ->
end,
mnesia:ets(F).
-spec get_pool_size(atom(), binary()) -> pos_integer().
get_pool_size(SQLType, Host) ->
PoolSize = ejabberd_config:get_option(
{sql_pool_size, Host},
fun(I) when is_integer(I), I>0 -> I end,
case SQLType of
sqlite -> 1;
_ -> ?DEFAULT_POOL_SIZE
end),
if PoolSize > 1 andalso SQLType == sqlite ->
?WARNING_MSG("it's not recommended to set sql_pool_size > 1 for "
"sqlite, because it may cause race conditions", []);
true ->
ok
end,
PoolSize.
transform_options(Opts) ->
lists:foldl(fun transform_options/2, [], Opts).