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:
parent
3908a80ac9
commit
3189bb3bb9
@ -61,10 +61,6 @@ start_link(Host) ->
|
|||||||
?MODULE, [Host]).
|
?MODULE, [Host]).
|
||||||
|
|
||||||
init([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(
|
StartInterval = ejabberd_config:get_option(
|
||||||
{sql_start_interval, Host},
|
{sql_start_interval, Host},
|
||||||
fun(I) when is_integer(I), I>0 -> I end,
|
fun(I) when is_integer(I), I>0 -> I end,
|
||||||
@ -76,6 +72,7 @@ init([Host]) ->
|
|||||||
(mssql) -> mssql;
|
(mssql) -> mssql;
|
||||||
(odbc) -> odbc
|
(odbc) -> odbc
|
||||||
end, odbc),
|
end, odbc),
|
||||||
|
PoolSize = get_pool_size(Type, Host),
|
||||||
case Type of
|
case Type of
|
||||||
sqlite ->
|
sqlite ->
|
||||||
check_sqlite_db(Host);
|
check_sqlite_db(Host);
|
||||||
@ -117,6 +114,23 @@ remove_pid(Host, Pid) ->
|
|||||||
end,
|
end,
|
||||||
mnesia:ets(F).
|
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) ->
|
transform_options(Opts) ->
|
||||||
lists:foldl(fun transform_options/2, [], Opts).
|
lists:foldl(fun transform_options/2, [], Opts).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user