diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-14 15:07:23 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-14 15:07:23 +0100 |
| commit | e90a269896ba8dcd538f5314356d7ff9170721a0 (patch) | |
| tree | 2f5805175873d92297c572990e573b8b0d2f12f0 /src | |
| parent | c357bcad38bdf86f9db8a499fe471cddb5e73342 (diff) | |
| download | rabbitmq-server-git-e90a269896ba8dcd538f5314356d7ff9170721a0.tar.gz | |
file2 will start the serialiser when it needs it
Diffstat (limited to 'src')
| -rw-r--r-- | src/file2.erl | 14 | ||||
| -rw-r--r-- | src/serialiser.erl | 11 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/file2.erl b/src/file2.erl index 4d945fc4a2..bcae00a340 100644 --- a/src/file2.erl +++ b/src/file2.erl @@ -900,13 +900,25 @@ mode_list(_) -> %% Functions for communicating with the file server call(Command, Args) when is_list(Args) -> + Pid = case whereis(serialiser) of + undefined -> start_serialiser(); + Pid2 -> Pid2 + end, serialiser:submit( - serialiser, + Pid, fun () -> gen_server:call(?FILE_SERVER, list_to_tuple([Command | Args]), infinity) end). +start_serialiser() -> + {ok, Pid} = supervisor:start_child(kernel_sup, + {serialiser, {serialiser, start_link, []}, + permanent, 16#ffffffff, worker, + [serialiser]}), + true = register(serialiser, Pid), + Pid. + check_and_call(Command, Args) when is_list(Args) -> case check_args(Args) of ok -> diff --git a/src/serialiser.erl b/src/serialiser.erl index 958f0d500c..0f9bcf17cd 100644 --- a/src/serialiser.erl +++ b/src/serialiser.erl @@ -43,15 +43,8 @@ start_link() -> gen_server2:start_link(?MODULE, [], [{timeout, infinity}]). -submit(Pid, Fun) when is_pid(Pid) -> - gen_server2:call(Pid, {run, Fun}, infinity); -submit(Server, Fun) -> - %% If the io_runner is not running, just run the Fun in the - %% current process. - case whereis(Server) of - undefined -> run(Fun); - _ -> gen_server2:call(Server, {run, Fun}, infinity) - end. +submit(Pid, Fun) -> + gen_server2:call(Pid, {run, Fun}, infinity). %%---------------------------------------------------------------------------- |
