~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/kernel/test/application_SUITE_data/deadlock/deadlock.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-module(deadlock).
 
2
-behaviour(application).
 
3
-compile(export_all).
 
4
-define(SUP,deadlock_sup).
 
5
-define(CHILD,deadlock_child).
 
6
 
 
7
 
 
8
%%%-----------------------------------------------------------------
 
9
%%% application callbacks
 
10
start(_StartType, _StartArgs) ->
 
11
    supervisor:start_link({local, ?SUP}, ?MODULE, [sup]).
 
12
 
 
13
stop(_State) ->
 
14
    ok.
 
15
 
 
16
 
 
17
 
 
18
%%%-----------------------------------------------------------------
 
19
%%% supervisor callbacks
 
20
init([sup]) ->
 
21
    {ok, {{one_for_one, 5, 10}, [
 
22
        {
 
23
            sasl_syslog_dm, {?MODULE, start_link, []},
 
24
            permanent, brutal_kill, worker,
 
25
            [deadlock]
 
26
        }
 
27
    ]}};
 
28
 
 
29
 
 
30
%%%-----------------------------------------------------------------
 
31
%%% gen_server callbacks
 
32
init([child]) ->
 
33
    case application:get_env(deadlock, fail_start) of
 
34
        {ok, false} ->
 
35
            %% we must not fail on the first init, otherwise supervisor
 
36
            %% terminates immediately
 
37
            {ok, []};
 
38
        {ok, true}  ->
 
39
            timer:sleep(infinity), % init hangs!!!!
 
40
            {ok, []}
 
41
    end.
 
42
 
 
43
handle_call(_Req, _From, State) ->
 
44
    {reply, ok, State}.
 
45
 
 
46
handle_cast(restart, State) ->
 
47
    {stop, error, State}.
 
48
 
 
49
handle_info(_Msg, State) ->
 
50
    {noreply, State}.
 
51
 
 
52
terminate(_Reason, _State) ->
 
53
    ok.
 
54
 
 
55
code_change(_OldVsn, State, _Extra) ->
 
56
    {ok, State}.
 
57
 
 
58
 
 
59
%%%-----------------------------------------------------------------
 
60
%%% Start child
 
61
start_link() ->
 
62
    gen_server:start_link({local, ?CHILD}, ?MODULE, [child], []).
 
63
 
 
64
 
 
65
%%%-----------------------------------------------------------------
 
66
%%% Provoke hanging
 
67
restart_and_fail() ->
 
68
    application:set_env(deadlock, fail_start, true), % next init will hang
 
69
    gen_server:cast(?CHILD, restart).