Skip to content

Commit 7429f0c

Browse files
Merge pull request #1482 from rabbitmq/rabbitmq-server-vhost-sup-sup-badarg
Only call vhost status for fully started nodes
2 parents 5b2c9be + 8a60207 commit 7429f0c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/rabbit_vhost_sup_sup.erl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,13 @@ start_vhost(VHost, Node) ->
183183
start_vhost(VHost) ->
184184
case rabbit_vhost:exists(VHost) of
185185
false -> {error, {no_such_vhost, VHost}};
186-
true -> supervisor2:start_child(?MODULE, [VHost])
186+
true ->
187+
case whereis(?MODULE) of
188+
Pid when is_pid(Pid) ->
189+
supervisor2:start_child(?MODULE, [VHost]);
190+
undefined ->
191+
{error, rabbit_vhost_sup_sup_not_running}
192+
end
187193
end.
188194

189195
-spec is_vhost_alive(rabbit_types:vhost()) -> boolean().
@@ -221,9 +227,13 @@ save_vhost_process(VHost, VHostProcessPid) ->
221227

222228
-spec lookup_vhost_sup_record(rabbit_types:vhost()) -> #vhost_sup{} | not_found.
223229
lookup_vhost_sup_record(VHost) ->
224-
case ets:lookup(?MODULE, VHost) of
225-
[] -> not_found;
226-
[#vhost_sup{} = VHostSup] -> VHostSup
230+
case ets:info(?MODULE, name) of
231+
?MODULE ->
232+
case ets:lookup(?MODULE, VHost) of
233+
[] -> not_found;
234+
[#vhost_sup{} = VHostSup] -> VHostSup
235+
end;
236+
undefined -> not_found
227237
end.
228238

229239
-spec vhost_sup_pid(rabbit_types:vhost()) -> no_pid | {ok, pid()}.

0 commit comments

Comments
 (0)