aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-11-08 09:51:40 +0100
committerDan Gudmundsson <[email protected]>2016-11-08 09:51:40 +0100
commit2d78b8d501ba9c108c735212a985e96792b79999 (patch)
tree596509dda516dacd3d2bff5627120bb0ecf0eb5e /lib/mnesia
parent0805ac891e3a048e0d7382dec84b8682ad9c6c9c (diff)
parentcd8438832471e7444eec7b78cd1aaee6779cc28a (diff)
downloadotp-2d78b8d501ba9c108c735212a985e96792b79999.tar.gz
otp-2d78b8d501ba9c108c735212a985e96792b79999.tar.bz2
otp-2d78b8d501ba9c108c735212a985e96792b79999.zip
Merge branch 'richcarl/mnesia-app-module/PR-1223'
* richcarl/mnesia-app-module/PR-1223: Make a separate application module for Mnesia
Diffstat (limited to 'lib/mnesia')
-rw-r--r--lib/mnesia/doc/src/Mnesia_chap3.xmlsrc2
-rw-r--r--lib/mnesia/src/Makefile1
-rw-r--r--lib/mnesia/src/mnesia.app.src5
-rw-r--r--lib/mnesia/src/mnesia.erl1
-rw-r--r--lib/mnesia/src/mnesia_app.erl41
-rw-r--r--lib/mnesia/src/mnesia_sup.erl33
6 files changed, 53 insertions, 30 deletions
diff --git a/lib/mnesia/doc/src/Mnesia_chap3.xmlsrc b/lib/mnesia/doc/src/Mnesia_chap3.xmlsrc
index 8f1a4366ee..ffda739dfa 100644
--- a/lib/mnesia/doc/src/Mnesia_chap3.xmlsrc
+++ b/lib/mnesia/doc/src/Mnesia_chap3.xmlsrc
@@ -348,7 +348,7 @@ skeppet %<input>erl -sname b -mnesia dir '"/ldisc/scratch/Mnesia.company"'</inpu
<p>If the startup procedure fails, the function
<seealso marker="mnesia#start/0">mnesia:start()</seealso>
returns the cryptic tuple
- <c>{error,{shutdown, {mnesia_sup,start,[normal,[]]}}}</c>.
+ <c>{error,{shutdown, {mnesia_sup,start_link,[normal,[]]}}}</c>.
To get more information about the start failure, use
command-line arguments <c>-boot start_sasl</c> as argument to
the <c>erl</c> script.</p>
diff --git a/lib/mnesia/src/Makefile b/lib/mnesia/src/Makefile
index 08a00e6aba..5206e469a5 100644
--- a/lib/mnesia/src/Makefile
+++ b/lib/mnesia/src/Makefile
@@ -43,6 +43,7 @@ RELSYSDIR = $(RELEASE_PATH)/lib/mnesia-$(VSN)
# ----------------------------------------------------
MODULES= \
mnesia \
+ mnesia_app \
mnesia_backend_type \
mnesia_backup \
mnesia_bup \
diff --git a/lib/mnesia/src/mnesia.app.src b/lib/mnesia/src/mnesia.app.src
index 006ad4bac1..af14826c90 100644
--- a/lib/mnesia/src/mnesia.app.src
+++ b/lib/mnesia/src/mnesia.app.src
@@ -3,6 +3,7 @@
{vsn, "%VSN%"},
{modules, [
mnesia,
+ mnesia_app,
mnesia_backend_type,
mnesia_backup,
mnesia_bup,
@@ -49,7 +50,5 @@
mnesia_tm
]},
{applications, [kernel, stdlib]},
- {mod, {mnesia_sup, []}},
+ {mod, {mnesia_app, []}},
{runtime_dependencies, ["stdlib-2.0","kernel-3.0","erts-7.0"]}]}.
-
-
diff --git a/lib/mnesia/src/mnesia.erl b/lib/mnesia/src/mnesia.erl
index 5bf2fc2dc3..9c7321ee43 100644
--- a/lib/mnesia/src/mnesia.erl
+++ b/lib/mnesia/src/mnesia.erl
@@ -273,6 +273,7 @@ kill() ->
ms() ->
[
mnesia,
+ mnesia_app,
mnesia_backup,
mnesia_bup,
mnesia_checkpoint,
diff --git a/lib/mnesia/src/mnesia_app.erl b/lib/mnesia/src/mnesia_app.erl
new file mode 100644
index 0000000000..4d89011db2
--- /dev/null
+++ b/lib/mnesia/src/mnesia_app.erl
@@ -0,0 +1,41 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1996-2016. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(mnesia_app).
+
+-behaviour(application).
+
+-export([start/2, stop/1]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% application callback functions
+
+start(normal, Args) ->
+ case mnesia_sup:start_link(Args) of
+ {ok, Pid} ->
+ {ok, Pid, {normal, Args}};
+ Error ->
+ Error
+ end;
+start(_, _) ->
+ {error, badarg}.
+
+stop(_StartArgs) ->
+ ok.
diff --git a/lib/mnesia/src/mnesia_sup.erl b/lib/mnesia/src/mnesia_sup.erl
index 4aece81308..3e5792900b 100644
--- a/lib/mnesia/src/mnesia_sup.erl
+++ b/lib/mnesia/src/mnesia_sup.erl
@@ -23,39 +23,21 @@
-module(mnesia_sup).
--behaviour(application).
-behaviour(supervisor).
--export([start/0, start/2, init/1, stop/1, start_event/0, kill/0]).
+-export([start_link/1, init/1, start_event/0, kill/0]).
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% application and suprvisor callback functions
-
-start(normal, Args) ->
- SupName = {local,?MODULE},
- case supervisor:start_link(SupName, ?MODULE, [Args]) of
- {ok, Pid} ->
- {ok, Pid, {normal, Args}};
- Error ->
- Error
- end;
-start(_, _) ->
- {error, badarg}.
-
-start() ->
- SupName = {local,?MODULE},
- supervisor:start_link(SupName, ?MODULE, []).
+start_link(Args) ->
+ supervisor:start_link({local,?MODULE}, ?MODULE, [Args]).
-stop(_StartArgs) ->
- ok.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% supervisor callback functions
-init([]) -> % Supervisor
- init();
-init([[]]) -> % Application
+init([[]]) ->
init();
init(BadArg) ->
{error, {badarg, BadArg}}.
-
+
init() ->
Flags = {one_for_all, 0, 3600}, % Should be rest_for_one policy
@@ -124,4 +106,3 @@ ensure_dead(Name) ->
timer:sleep(10),
ensure_dead(Name)
end.
-