Skip to content

Commit b3292df

Browse files
authored
Merge pull request #4524 from esl/startup_optimisations
Rework startup order and FIPS config
2 parents 8e3acc6 + 70c2a99 commit b3292df

34 files changed

+154
-347
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ rock:
4141

4242
## Don't allow these files to go out of sync!
4343
configure.out rel/configure.vars.config:
44-
./tools/configure with-all without-jingle-sip
44+
./tools/configure
4545

4646
devrel: $(DEVNODES)
4747

big_tests/rebar.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{erl_opts, [debug_info,
2-
{i, ["include"]},
3-
{platform_define, "^(20)", fun_stacktrace}]}.
2+
{i, ["include"]}]}.
43

54
{require_min_otp_vsn, "21"}.
65

big_tests/tests/jingle_SUITE.erl

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,15 @@ suite() ->
5656
%%--------------------------------------------------------------------
5757

5858
init_per_suite(Config) ->
59-
case rpc(mim(), application, get_application, [nksip]) of
60-
{ok, nksip} ->
61-
distributed_helper:add_node_to_cluster(mim2(), Config),
62-
start_nksip_in_mim_nodes(),
63-
application:ensure_all_started(esip),
64-
spawn(fun() -> ets:new(jingle_sip_translator, [public, named_table]),
65-
ets:new(jingle_sip_translator_bindings, [public, named_table]),
66-
receive stop -> ok end end),
67-
esip:add_listener(12345, tcp, []),
68-
esip:set_config_value(module, jingle_sip_translator),
69-
escalus:init_per_suite(Config);
70-
undefined ->
71-
{skip, build_was_not_configured_with_jingle_sip}
72-
end.
59+
distributed_helper:add_node_to_cluster(mim2(), Config),
60+
start_nksip_in_mim_nodes(),
61+
application:ensure_all_started(esip),
62+
spawn(fun() -> ets:new(jingle_sip_translator, [public, named_table]),
63+
ets:new(jingle_sip_translator_bindings, [public, named_table]),
64+
receive stop -> ok end end),
65+
esip:add_listener(12345, tcp, []),
66+
esip:set_config_value(module, jingle_sip_translator),
67+
escalus:init_per_suite(Config).
7368

7469
start_nksip_in_mim_nodes() ->
7570
Pid1 = start_nskip_in_parallel(mim(), #{}),

doc/developers-guide/OpenSSL-and-FIPS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where `Value` is either `true` or `false`.
5151
When MongooseIM starts, it prints the following log message if FIPS mode is enabled
5252

5353
```
54-
2015-02-25 14:30:54.501 [warning] <0.242.0>@mongoose_fips:do_notify:37 FIPS mode enabled
54+
2015-02-25 14:30:54.501 [warning] <0.242.0>@mongoose_fips:notify:15 FIPS mode enabled
5555
```
5656

5757
### Run-time check
@@ -64,9 +64,9 @@ mongoose_fips:status().
6464

6565
The function returns:
6666

67+
* not_supported - erlang compiled without fips support
6768
* not_enabled - fips_mode is not set to true in etc/app.config
6869
* enabled - fips_mode is set to true in etc/app.config
69-
* not_supported - erlang compiled without fips support
7070

7171
### Cipher suites difference
7272

doc/developers-guide/release_config.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ Writes configure.out file as output - this file can be sourced with:
2626
2727
Writes rel/configure.vars.config which can be used as Reltool input.
2828
29-
3rd party apps:
30-
31-
with-none include no 3rd party drivers
32-
with-all include all drivers
33-
with-mysql include mysql driver
34-
with-odbc include an ODBC driver (requires unixodbc to compile)
35-
with-pgsql include pgsql driver
36-
with-redis include redis driver
37-
3829
Options:
3930
4031
prefix Installation PREFIX directory. Default: /usr/local
@@ -44,13 +35,6 @@ Options:
4435

4536
This script is also accessible via the make `configure` target.
4637

47-
### Example
48-
49-
If `mysql` and `redis` are the only drivers that should be included in the
50-
release, run the following command before `make rel`:
51-
52-
$ ./tools/configure with-mysql with-redis
53-
5438
You only need to run the `./tools/configure` command once (unless changing the release's config is needed to
5539
include some other dependencies).
5640

@@ -63,7 +47,7 @@ Results should be similar to those described below.
6347
On Mac:
6448

6549
```sh
66-
./tools/configure with-all user=erszcz prefix=/tmp/mim-sandbox-system system=yes
50+
./tools/configure user=erszcz prefix=/tmp/mim-sandbox-system system=yes
6751
cat configure.out rel/configure.vars.config
6852
RUNNER_GROUP=staff make install
6953
```

doc/modules/mod_jingle_sip.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,6 @@ This may be useful in web applications when there is a need to handle the call i
8383
In order to get the `session-initiate`, which was not answered yet, the user can send a `get` Jingle stanza to self with action set to `existing-session-initiate`.
8484
As a result, MongooseIM will resend the original `session-initiate` request to the device which sent the query.
8585

86-
## Prerequisites
87-
88-
By default, MongooseIM is built without SIP support.
89-
In order to build the server with SIP support, please use `tools/configure` script before the release generation.
90-
You may either pick only certain drivers (with SIP included) or simply use `with-all` option. Examples:
91-
92-
```
93-
tools/configure with-mysql with-jingle-sip
94-
tools/configure with-all without-odbc
95-
tools/configure with-all
96-
```
97-
98-
MongooseIM packages are built with Jingle/SIP support.
99-
10086
!!! warning
10187
This module does not support [dynamic domains](../configuration/general.md#generalhost_types).
10288

doc/tutorials/Jingle-SIP-setup.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ We are going to use the following open source software:
88

99
* MongooseIM - [https://github.com/esl/MongooseIM](https://github.com/esl/MongooseIM)
1010
* see [How-to-build](How-to-build.md) for details on building.
11-
It's important to remember to run the configuration script with `with-jingle-sip` flag set:
12-
`tools/configure with-jingle-sip`.
13-
Without this, third party dependencies required by the Jingle/SIP translator will not be included in the release.
1411

1512
* Routr (SIP server) - [https://routr.io](https://routr.io)
1613
* I recommend downloading binaries for your system from [official source](https://routr.io/docs/introduction/installation/#custom).

rebar.config

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{erl_opts, [debug_info,
2-
{i, ["include"]},
3-
{d, xml_nif},
4-
{d, namespaced_types},
5-
{platform_define, "^(20)", fun_stacktrace},
6-
{platform_define, "^(25)", gen_server_request_id}]}.
2+
{i, ["include"]}]}.
73

84
%% For behaviour info
95
{erl_first_files, [
@@ -25,7 +21,7 @@
2521
mod_global_distrib_mapping_backend,
2622
mod_pubsub_db_backend,
2723
mod_shared_roster,
28-
ejabberd_c2s, ejabberd_c2s_state, ejabberd_local,
24+
ejabberd_local,
2925
mongoose_c2s,
3026
mongoose_c2s_acc,
3127
%% Deprecated functions
@@ -113,8 +109,7 @@
113109
{luerl, "1.3.0"}
114110
]}.
115111

116-
{relx, [{release, { mongooseim, {cmd, "cat VERSION | tr -d '\r\n'"} },
117-
[]}, %%Apps list is dynamicaly set by rebar.config.script
112+
{relx, [{release, {mongooseim, {file, "VERSION"}}, []}, %%Apps list is dynamicaly set by rebar.config.script
118113

119114
%% Disable some warnings in systools:make_script/2 which are extremely slow (saves 30 seconds)
120115
{src_tests, false},
@@ -224,7 +219,8 @@
224219
{plt_extra_apps, [jid, cowboy, cowlib, lasse, p1_utils, ranch, gen_fsm_compat, epgsql, cqerl,
225220
common_test, tools, amqp_client, jiffy, erl_csv, inets, compiler, jsx,
226221
rabbit_common, mysql, eredis, erlcloud, eodbc, telemetry,
227-
nksip, nklib, nkservice, nkpacket, prometheus]}]}.
222+
nksip, nklib, nkservice, nkpacket, prometheus, exometer_core,
223+
mnesia, cets, cpool, tirerl, erlang_doctor]}]}.
228224

229225
{cover_print_enabled, true}.
230226
{cover_export_enabled, true}.

rebar.config.script

Lines changed: 39 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,39 @@
1-
os:putenv("EXOMETER_PACKAGES", "(minimal)"),
2-
3-
MaybeReadFromConfig =
4-
fun ({ok, Content}) ->
5-
Parts = binary:split(Content, <<"\n">>, [global]),
6-
%% find only this line which starts with "export APPS="
7-
[Apps] = [Item || <<"export APPS=\"",Item/binary>> <- Parts],
8-
%% remove trailing " and conver to string
9-
binary_to_list(binary:part(Apps, 0, size(Apps) - 1));
10-
(_) ->
11-
io:format("WARNING! The configure.out file was not created, using minimal configuration~n"),
12-
""
13-
end,
14-
15-
ReadFromConfig =
16-
fun(Path) ->
17-
case filelib:is_file(Path) of
18-
true ->
19-
MaybeReadFromConfig(file:read_file(Path));
20-
_ ->
21-
Script = filename:join(["tools", "configure"]),
22-
os:cmd(Script ++ " with-all without-jingle-sip"),
23-
MaybeReadFromConfig(file:read_file("configure.out"))
24-
end
25-
end,
26-
27-
GetEnvApps =
28-
fun() ->
29-
case os:getenv("APPS") of
30-
false ->
31-
ConfigurePath = "configure.out",
32-
ReadFromConfig(ConfigurePath);
33-
EnvApps ->
34-
EnvApps
35-
end
36-
end,
37-
38-
DevAppsToInclude =
39-
fun() ->
40-
case os:getenv("DEVNODE") of
41-
false -> [];
42-
_ -> [meck]
43-
end
44-
end,
45-
46-
FirstApps = [kernel],
47-
RequiredApps = [mongooseim, inets, tools, compiler],
48-
OptionalApps = [{nksip, [nkservice, nkpacket, nklib]}],
49-
50-
EnvApps = GetEnvApps(),
51-
52-
PrepareApp =
53-
fun(App) ->
54-
case lists:keyfind(App, 1, OptionalApps) of
55-
false ->
56-
[App];
57-
{App, DepsOfApp} ->
58-
lists:map(fun(V) -> {V, load} end, [App | DepsOfApp])
59-
end
60-
end,
61-
62-
SetupIncludedApps =
63-
fun(Config, EnvApps) ->
64-
RelxCfg = proplists:get_value(relx, Config),
65-
{release, Desc, _Apps} = lists:keyfind(release, 1, RelxCfg),
66-
EnvAppsToInclude = [ list_to_atom(App) || App <- string:tokens(EnvApps, " \n\r") ],
67-
AppsToIncludeIn = lists:usort(RequiredApps ++ DevAppsToInclude() ++ EnvAppsToInclude),
68-
Apps = lists:subtract(AppsToIncludeIn, FirstApps),
69-
NewReleaseCfg = {release, Desc, FirstApps ++ lists:flatmap(PrepareApp, Apps)},
70-
NewRelxCfg = lists:keyreplace(release, 1, RelxCfg, NewReleaseCfg),
71-
lists:keyreplace(relx, 1, Config, {relx, NewRelxCfg})
72-
end,
73-
74-
MaybeFIPSSupport = fun(Config) ->
75-
code:ensure_loaded(crypto),
76-
case erlang:function_exported(crypto, info_fips, 0) of
77-
false ->
78-
Config;
79-
_ ->
80-
io:format("compiling with FIPS mode enabled~n"),
81-
{erl_opts, ErlOpts} = lists:keyfind(erl_opts, 1, Config),
82-
NewErlOpts = [{d, fips_mode} | ErlOpts],
83-
lists:keyreplace(erl_opts, 1, Config, {erl_opts, NewErlOpts})
84-
end
85-
end,
86-
87-
Config0 = SetupIncludedApps(CONFIG, EnvApps),
88-
MaybeFIPSSupport(Config0).
1+
BaseApps = [kernel, stdlib, sasl,
2+
crypto, inets, public_key, ssl,
3+
tools, runtime_tools,
4+
mongooseim,
5+
{mnesia, none},
6+
{erlang_doctor, none},
7+
{syslogger, none},
8+
{cpool, none},
9+
{backoff, none},
10+
{mysql, none},
11+
{eodbc, none},
12+
{epgsql, none},
13+
{eredis, none},
14+
{cqerl, none},
15+
{tirerl, none},
16+
{erlcloud, none},
17+
{amqp_client, none},
18+
{exometer_core, none},
19+
{exometer_report_graphite, none},
20+
{exometer_report_statsd, none},
21+
{prometheus, none},
22+
{prometheus_httpd, none},
23+
{prometheus_cowboy, none},
24+
{nksip, none},
25+
{nkservice, none},
26+
{nkpacket, none},
27+
{nklib, none}
28+
],
29+
30+
Apps = case os:getenv("DEVNODE") of
31+
false -> BaseApps;
32+
_ -> [meck | BaseApps]
33+
end,
34+
35+
{relx, RelxCfg} = lists:keyfind(relx, 1, CONFIG),
36+
{release, Desc, _Apps} = lists:keyfind(release, 1, RelxCfg),
37+
NewReleaseCfg = {release, Desc, Apps},
38+
NewRelxCfg = lists:keyreplace(release, 1, RelxCfg, NewReleaseCfg),
39+
lists:keyreplace(relx, 1, CONFIG, {relx, NewRelxCfg}).

src/async_pools/mongoose_aggregator_worker.erl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@
1616

1717
-behaviour(gen_server).
1818

19-
-ifdef(gen_server_request_id).
20-
-type request_id() :: gen_server:request_id().
21-
-else.
22-
-type request_id() :: term().
23-
-endif.
24-
2519
-callback aggregate(mongoose_async_pools:task(),
2620
mongoose_async_pools:task(),
2721
mongoose_async_pools:pool_extra()) ->
2822
{ok, mongoose_async_pools:task()} | {error, term()}.
2923
-callback request(mongoose_async_pools:task(), mongoose_async_pools:pool_extra()) ->
30-
request_id() | drop.
24+
gen_server:request_id() | drop.
3125
-callback verify(term(), mongoose_async_pools:task(), mongoose_async_pools:pool_extra()) ->
3226
term().
3327
-optional_callbacks([verify/3]).
@@ -43,7 +37,7 @@
4337
code_change/3,
4438
format_status/1]).
4539

46-
-type request() :: no_request_pending | {request_id(), mongoose_async_pools:task()}.
40+
-type request() :: no_request_pending | {gen_server:request_id(), mongoose_async_pools:task()}.
4741
-record(state, {
4842
host_type :: mongooseim:host_type(),
4943
pool_id :: mongoose_async_pools:pool_id(),

0 commit comments

Comments
 (0)