Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Enforce per-vhost connection limit
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Feb 18, 2016
1 parent 7e34dca commit b78d3d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/rabbit.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@
location}). %% string()

%% used to track connections across virtual hosts
%% e.g. so that limits can be enforced
%% so that limits can be enforced
-record(tracked_connection_per_vhost,
{vhost, connection_count}).

%% Used to track detailed information
%% about connections.
-record(tracked_connection, {
%% {Node, Name}
id,
Expand Down
7 changes: 7 additions & 0 deletions src/rabbit_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,13 @@ handle_method0(#'connection.open'{virtual_host = VHostPath},
helper_sup = SupPid,
sock = Sock,
throttle = Throttle}) ->
case rabbit_connection_tracking:is_over_connection_limit(VHostPath) of
false -> ok;
{true, Limit} -> rabbit_misc:protocol_error(not_allowed,
"access to vhost '~s' refused for user '~s': "
"connection limit (~p) is reached",
[VHostPath, User#user.username, Limit])
end,
ok = rabbit_access_control:check_vhost_access(User, VHostPath, Sock),
NewConnection = Connection#connection{vhost = VHostPath},
ok = send_on_channel0(Sock, #'connection.open_ok'{}, Protocol),
Expand Down

0 comments on commit b78d3d2

Please sign in to comment.