diff options
| author | Daniil Fedotov <dfedotov@pivotal.io> | 2017-09-11 16:53:05 +0100 |
|---|---|---|
| committer | Daniil Fedotov <dfedotov@pivotal.io> | 2017-09-11 16:53:05 +0100 |
| commit | 920c12443f6353bc63703497ae438ef30950aded (patch) | |
| tree | 37b5fa48b73319a9a43bdefab922e3bba4b624b4 /src | |
| parent | bee9a4238e2731a6bf371481056f02a940c1beb4 (diff) | |
| download | rabbitmq-server-git-920c12443f6353bc63703497ae438ef30950aded.tar.gz | |
Do not start direct connections if the direct connection supervisor is not started
Starting a direct connection when the supervisor is not started
will result in connection termination right after start,
the client will have a pid at this moment, which can cause
a confusing error.
Return error if it's clear that the connection cannot be started.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_direct.erl | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl index 3c3da5ef7a..d01d004a1d 100644 --- a/src/rabbit_direct.erl +++ b/src/rabbit_direct.erl @@ -80,17 +80,23 @@ connect({Username, Password}, VHost, Protocol, Pid, Infos) -> connect0(AuthFun, VHost, Protocol, Pid, Infos) -> case rabbit:is_running() of - true -> case AuthFun() of - {ok, User = #user{username = Username}} -> - notify_auth_result(Username, - user_authentication_success, []), - connect1(User, VHost, Protocol, Pid, Infos); - {refused, Username, Msg, Args} -> - notify_auth_result(Username, - user_authentication_failure, - [{error, rabbit_misc:format(Msg, Args)}]), - {error, {auth_failure, "Refused"}} - end; + true -> + case whereis(rabbit_direct_client_sup) of + undefined -> + {error, broker_is_booting}; + _ -> + case AuthFun() of + {ok, User = #user{username = Username}} -> + notify_auth_result(Username, + user_authentication_success, []), + connect1(User, VHost, Protocol, Pid, Infos); + {refused, Username, Msg, Args} -> + notify_auth_result(Username, + user_authentication_failure, + [{error, rabbit_misc:format(Msg, Args)}]), + {error, {auth_failure, "Refused"}} + end + end; false -> {error, broker_not_found_on_node} end. |
