Skip to content

Commit 0527df3

Browse files
Merge pull request #1357 from rabbitmq/rabbitmq-server-1356
Do not start direct connections if the direct connection supervisor is not started
2 parents bee9a42 + 920c124 commit 0527df3

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/rabbit_direct.erl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,23 @@ connect({Username, Password}, VHost, Protocol, Pid, Infos) ->
8080

8181
connect0(AuthFun, VHost, Protocol, Pid, Infos) ->
8282
case rabbit:is_running() of
83-
true -> case AuthFun() of
84-
{ok, User = #user{username = Username}} ->
85-
notify_auth_result(Username,
86-
user_authentication_success, []),
87-
connect1(User, VHost, Protocol, Pid, Infos);
88-
{refused, Username, Msg, Args} ->
89-
notify_auth_result(Username,
90-
user_authentication_failure,
91-
[{error, rabbit_misc:format(Msg, Args)}]),
92-
{error, {auth_failure, "Refused"}}
93-
end;
83+
true ->
84+
case whereis(rabbit_direct_client_sup) of
85+
undefined ->
86+
{error, broker_is_booting};
87+
_ ->
88+
case AuthFun() of
89+
{ok, User = #user{username = Username}} ->
90+
notify_auth_result(Username,
91+
user_authentication_success, []),
92+
connect1(User, VHost, Protocol, Pid, Infos);
93+
{refused, Username, Msg, Args} ->
94+
notify_auth_result(Username,
95+
user_authentication_failure,
96+
[{error, rabbit_misc:format(Msg, Args)}]),
97+
{error, {auth_failure, "Refused"}}
98+
end
99+
end;
94100
false -> {error, broker_not_found_on_node}
95101
end.
96102

0 commit comments

Comments
 (0)