diff options
| author | Ayanda-D <ayanda.dube@erlang-solutions.com> | 2020-06-09 13:00:55 +0100 |
|---|---|---|
| committer | Michael Klishin <michael@clojurewerkz.org> | 2020-09-02 04:28:58 +0300 |
| commit | 275cecce2f9f429a77190712ad3f45afcbc31459 (patch) | |
| tree | a13a09e23d2971ab3c78ec4730cc4f2345c1557c | |
| parent | faa63c3089bb8ddf2643f0c824638a0fc2c9d90e (diff) | |
| download | rabbitmq-server-git-275cecce2f9f429a77190712ad3f45afcbc31459.tar.gz | |
Update connection/channel limit context and error messages
in rabbit_direct
| -rw-r--r-- | src/rabbit_direct.erl | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl index 98eef21104..b5f068cbee 100644 --- a/src/rabbit_direct.erl +++ b/src/rabbit_direct.erl @@ -82,7 +82,7 @@ connect(Creds, VHost, Protocol, Pid, Infos) -> undefined -> {error, broker_is_booting}; _ -> - case is_over_connection_limit(VHost, Creds, Pid) of + case is_over_vhost_connection_limit(VHost, Creds, Pid) of true -> {error, not_allowed}; false -> @@ -102,7 +102,7 @@ connect(Creds, VHost, Protocol, Pid, Infos) -> {error, {auth_failure, "Refused"}} end %% AuthFun() end %% is_vhost_alive - end %% is_over_connection_limit + end %% is_over_vhost_connection_limit end; false -> {error, broker_not_found_on_node} end. @@ -148,7 +148,7 @@ is_vhost_alive(VHost, {Username, _Password}, Pid) -> false end. -is_over_connection_limit(VHost, {Username, _Password}, Pid) -> +is_over_vhost_connection_limit(VHost, {Username, _Password}, Pid) -> PrintedUsername = case Username of none -> ""; _ -> Username @@ -159,7 +159,7 @@ is_over_connection_limit(VHost, {Username, _Password}, Pid) -> rabbit_log_connection:error( "Error on Direct connection ~p~n" "access to vhost '~s' refused for user '~s': " - "connection limit (~p) is reached", + "vhost connection limit (~p) is reached", [Pid, VHost, PrintedUsername, Limit]), true catch @@ -194,9 +194,13 @@ connect1(User = #user{username = Username}, VHost, Protocol, Pid, Infos) -> {error, Reason} end; {true, Limit} -> - {error, rabbit_misc:format("Connection refused for user ~s. User " - "connection limit (~p) is reached", [Username, Limit])} - end. + rabbit_log_connection:error( + "Error on Direct connection ~p~n" + "access refused for user '~s': " + "user connection limit (~p) is reached", + [Pid, Username, Limit]), + {error, not_allowed} + end. -spec start_channel (rabbit_channel:channel_number(), pid(), pid(), string(), @@ -215,9 +219,13 @@ start_channel(Number, ClientChannelPid, ConnPid, ConnName, Protocol, [{direct, Number, ClientChannelPid, ConnPid, ConnName, Protocol, User, VHost, Capabilities, Collector, AmqpParams}]), {ok, ChannelPid}; - {true, Limit} -> {error, rabbit_misc:format("Not allowed. Number of " - "channels opened for user (~w) has reached the " - "maximum allowed limit of (~w)", [Username, Limit])} + {true, Limit} -> + rabbit_log_connection:error( + "Error on Direct connection ~p~n" + "number of channels opened for user (~w) has reached the " + "maximum allowed limit of (~w)", + [ConnPid, Username, Limit]), + {error, not_allowed} end. -spec disconnect(pid(), rabbit_event:event_props()) -> 'ok'. |
