diff options
author | Siri Hansen <[email protected]> | 2012-03-05 11:49:34 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2012-03-05 11:49:34 +0100 |
commit | 30f47279844cc9d6d2b7cfb0a2014d11719d1931 (patch) | |
tree | b530886f60de4a098d0e8a7cde8c9e70804436c3 /lib/stdlib/test/supervisor_deadlock.erl | |
parent | 3b5986433fb9f62feffa117f5643d53a42ef7652 (diff) | |
parent | 096ed7e301ce16dfb69709d7001ea3d5f370c202 (diff) | |
download | otp-30f47279844cc9d6d2b7cfb0a2014d11719d1931.tar.gz otp-30f47279844cc9d6d2b7cfb0a2014d11719d1931.tar.bz2 otp-30f47279844cc9d6d2b7cfb0a2014d11719d1931.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/stdlib/test/supervisor_deadlock.erl')
-rw-r--r-- | lib/stdlib/test/supervisor_deadlock.erl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/stdlib/test/supervisor_deadlock.erl b/lib/stdlib/test/supervisor_deadlock.erl new file mode 100644 index 0000000000..288547a972 --- /dev/null +++ b/lib/stdlib/test/supervisor_deadlock.erl @@ -0,0 +1,45 @@ +-module(supervisor_deadlock). +-compile(export_all). + + +%%%----------------------------------------------------------------- +%%% gen_server callbacks +init([child]) -> + case ets:lookup(supervisor_deadlock,fail_start) of + [{fail_start, false}] -> + %% we must not fail on the first init, otherwise supervisor + %% terminates immediately + {ok, []}; + [{fail_start, true}] -> + %% Restart frequency is MaxR=8, MaxT=10, so this will + %% ensure that restart intensity is not reached -> restart + %% loop + timer:sleep(2000), % NOTE: this could be a gen_server call timeout + + {stop, error} + end. + +handle_call(_Req, _From, State) -> + {reply, ok, State}. + +%% Force a restart +handle_cast(restart, State) -> + {stop, error, State}. + +handle_info(_Msg, State) -> + {noreply, State}. + +terminate(_Reason, _State) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + + +%%%----------------------------------------------------------------- +%%% Start child +start_child() -> + gen_server:start_link({local, ?MODULE}, ?MODULE, [child], []). + +restart_child() -> + gen_server:cast(supervisor_deadlock, restart). |