diff options
| author | Daniil Fedotov <hairyhum@gmail.com> | 2018-01-23 18:28:03 +0000 |
|---|---|---|
| committer | Daniil Fedotov <hairyhum@gmail.com> | 2018-01-23 18:31:19 +0000 |
| commit | b54e6018eccc72dfa4eb1bb68bd65e64ed382e18 (patch) | |
| tree | e7dc1db1decd59ed3e70975c7c52904d426dcd8e /src | |
| parent | affb941c94de205c304b8e4ea2dc3270896fe9bc (diff) | |
| download | rabbitmq-server-git-b54e6018eccc72dfa4eb1bb68bd65e64ed382e18.tar.gz | |
Make it safier to call RPCs if a supervisor is not started yet.
[#154569776]
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_vhost_sup_sup.erl | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/rabbit_vhost_sup_sup.erl b/src/rabbit_vhost_sup_sup.erl index 19d7cf61b7..558648400a 100644 --- a/src/rabbit_vhost_sup_sup.erl +++ b/src/rabbit_vhost_sup_sup.erl @@ -183,7 +183,13 @@ start_vhost(VHost, Node) -> start_vhost(VHost) -> case rabbit_vhost:exists(VHost) of false -> {error, {no_such_vhost, VHost}}; - true -> supervisor2:start_child(?MODULE, [VHost]) + true -> + case whereis(?MODULE) of + Pid when is_pid(Pid) -> + supervisor2:start_child(?MODULE, [VHost]); + undefined -> + {error, rabbit_vhost_sup_sup_not_running} + end end. -spec is_vhost_alive(rabbit_types:vhost()) -> boolean(). @@ -221,9 +227,13 @@ save_vhost_process(VHost, VHostProcessPid) -> -spec lookup_vhost_sup_record(rabbit_types:vhost()) -> #vhost_sup{} | not_found. lookup_vhost_sup_record(VHost) -> - case ets:lookup(?MODULE, VHost) of - [] -> not_found; - [#vhost_sup{} = VHostSup] -> VHostSup + case ets:info(?MODULE, name) of + ?MODULE -> + case ets:lookup(?MODULE, VHost) of + [] -> not_found; + [#vhost_sup{} = VHostSup] -> VHostSup + end; + undefined -> not_found end. -spec vhost_sup_pid(rabbit_types:vhost()) -> no_pid | {ok, pid()}. |
