diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-05-21 18:56:57 +0200 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-05-21 18:56:57 +0200 |
| commit | 3a76c1536748ba2a684b5e815f20bb7f8b6f29a4 (patch) | |
| tree | b7f209e906c69c4e995ee15bbbd6afacf71d33a3 /src/rabbit.erl | |
| parent | 79da7e3a17b07425797acbb5dfd76821799c6b69 (diff) | |
| parent | b710efcbf80867334bdffe4bd71990eafd44285d (diff) | |
| download | rabbitmq-server-git-3a76c1536748ba2a684b5e815f20bb7f8b6f29a4.tar.gz | |
Merge branch 'rabbitmq-server-157' into stable
Diffstat (limited to 'src/rabbit.erl')
| -rw-r--r-- | src/rabbit.erl | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 24883dc6d4..ee87739337 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -885,6 +885,33 @@ config_setting() -> %% We don't want this in fhc since it references rabbit stuff. And we can't put %% this in the bootstep directly. start_fhc() -> - rabbit_sup:start_restartable_child( + ok = rabbit_sup:start_restartable_child( file_handle_cache, - [fun rabbit_alarm:set_alarm/1, fun rabbit_alarm:clear_alarm/1]). + [fun rabbit_alarm:set_alarm/1, fun rabbit_alarm:clear_alarm/1]), + ensure_working_fhc(). + +ensure_working_fhc() -> + %% To test the file handle cache, we simply read a file we know it + %% exists (Erlang kernel's .app file). + %% + %% To avoid any pollution of the application process' dictionary by + %% file_handle_cache, we spawn a separate process. + Parent = self(), + TestFun = fun() -> + Filename = filename:join(code:lib_dir(kernel, ebin), "kernel.app"), + {ok, Fd} = file_handle_cache:open(Filename, [raw, binary, read], []), + {ok, _} = file_handle_cache:read(Fd, 1), + ok = file_handle_cache:close(Fd), + Parent ! fhc_ok + end, + TestPid = spawn_link(TestFun), + %% Because we are waiting for the test fun, abuse the + %% 'mnesia_table_loading_timeout' parameter to find a sane timeout + %% value. + Timeout = rabbit_table:wait_timeout(), + receive + fhc_ok -> ok; + {'EXIT', TestPid, Exception} -> throw({ensure_working_fhc, Exception}) + after Timeout -> + throw({ensure_working_fhc, {timeout, TestPid}}) + end. |
