@@ -567,7 +567,7 @@ handle_other(handshake_timeout, State) ->
567
567
throw ({handshake_timeout , State # v1 .callback });
568
568
handle_other (heartbeat_timeout , State = # v1 {connection_state = closed }) ->
569
569
State ;
570
- handle_other (heartbeat_timeout ,
570
+ handle_other (heartbeat_timeout ,
571
571
State = # v1 {connection = # connection {timeout_sec = T }}) ->
572
572
maybe_emit_stats (State ),
573
573
throw ({heartbeat_timeout , T });
@@ -623,7 +623,7 @@ send_blocked(#v1{connection = #connection{protocol = Protocol,
623
623
sock = Sock }, Reason ) ->
624
624
case rabbit_misc :table_lookup (Capabilities , <<" connection.blocked" >>) of
625
625
{bool , true } ->
626
-
626
+
627
627
ok = send_on_channel0 (Sock , # 'connection.blocked' {reason = Reason },
628
628
Protocol );
629
629
_ ->
@@ -1164,6 +1164,7 @@ handle_method0(#'connection.open'{virtual_host = VHost},
1164
1164
1165
1165
ok = is_over_connection_limit (VHost , User ),
1166
1166
ok = rabbit_access_control :check_vhost_access (User , VHost , Sock ),
1167
+ ok = is_vhost_alive (VHost , User ),
1167
1168
NewConnection = Connection # connection {vhost = VHost },
1168
1169
ok = send_on_channel0 (Sock , # 'connection.open_ok' {}, Protocol ),
1169
1170
@@ -1209,6 +1210,16 @@ handle_method0(_Method, #v1{connection_state = S}) ->
1209
1210
rabbit_misc :protocol_error (
1210
1211
channel_error , " unexpected method in connection state ~w " , [S ]).
1211
1212
1213
+ is_vhost_alive (VHostPath , User ) ->
1214
+ case rabbit_vhost_sup_sup :is_vhost_alive (VHostPath ) of
1215
+ true -> ok ;
1216
+ false ->
1217
+ rabbit_misc :protocol_error (internal_error ,
1218
+ " access to vhost '~s ' refused for user '~s ': "
1219
+ " vhost '~s ' is down" ,
1220
+ [VHostPath , User # user .username , VHostPath ])
1221
+ end .
1222
+
1212
1223
is_over_connection_limit (VHostPath , User ) ->
1213
1224
try rabbit_vhost_limit :is_over_connection_limit (VHostPath ) of
1214
1225
false -> ok ;
@@ -1567,7 +1578,7 @@ maybe_block(State = #v1{connection_state = CS, throttle = Throttle}) ->
1567
1578
State1 = State # v1 {connection_state = blocked ,
1568
1579
throttle = update_last_blocked_at (Throttle )},
1569
1580
case CS of
1570
- running ->
1581
+ running ->
1571
1582
ok = rabbit_heartbeat :pause_monitor (State # v1 .heartbeater );
1572
1583
_ -> ok
1573
1584
end ,
@@ -1589,7 +1600,7 @@ maybe_send_unblocked(State = #v1{throttle = Throttle}) ->
1589
1600
case should_send_unblocked (Throttle ) of
1590
1601
true ->
1591
1602
ok = send_unblocked (State ),
1592
- State # v1 {throttle =
1603
+ State # v1 {throttle =
1593
1604
Throttle # throttle {connection_blocked_message_sent = false }};
1594
1605
false -> State
1595
1606
end .
@@ -1598,7 +1609,7 @@ maybe_send_blocked_or_unblocked(State = #v1{throttle = Throttle}) ->
1598
1609
case should_send_blocked (Throttle ) of
1599
1610
true ->
1600
1611
ok = send_blocked (State , blocked_by_message (Throttle )),
1601
- State # v1 {throttle =
1612
+ State # v1 {throttle =
1602
1613
Throttle # throttle {connection_blocked_message_sent = true }};
1603
1614
false -> maybe_send_unblocked (State )
1604
1615
end .
@@ -1624,7 +1635,7 @@ control_throttle(State = #v1{connection_state = CS,
1624
1635
running -> maybe_block (State1 );
1625
1636
% % unblock or re-enable blocking
1626
1637
blocked -> maybe_block (maybe_unblock (State1 ));
1627
- _ -> State1
1638
+ _ -> State1
1628
1639
end .
1629
1640
1630
1641
augment_connection_log_name (# connection {client_properties = ClientProperties ,
0 commit comments