@@ -567,7 +567,7 @@ handle_other(handshake_timeout, State) ->
567567 throw ({handshake_timeout , State # v1 .callback });
568568handle_other (heartbeat_timeout , State = # v1 {connection_state = closed }) ->
569569 State ;
570- handle_other (heartbeat_timeout ,
570+ handle_other (heartbeat_timeout ,
571571 State = # v1 {connection = # connection {timeout_sec = T }}) ->
572572 maybe_emit_stats (State ),
573573 throw ({heartbeat_timeout , T });
@@ -623,7 +623,7 @@ send_blocked(#v1{connection = #connection{protocol = Protocol,
623623 sock = Sock }, Reason ) ->
624624 case rabbit_misc :table_lookup (Capabilities , <<" connection.blocked" >>) of
625625 {bool , true } ->
626-
626+
627627 ok = send_on_channel0 (Sock , # 'connection.blocked' {reason = Reason },
628628 Protocol );
629629 _ ->
@@ -1164,6 +1164,7 @@ handle_method0(#'connection.open'{virtual_host = VHost},
11641164
11651165 ok = is_over_connection_limit (VHost , User ),
11661166 ok = rabbit_access_control :check_vhost_access (User , VHost , Sock ),
1167+ ok = is_vhost_alive (VHost , User ),
11671168 NewConnection = Connection # connection {vhost = VHost },
11681169 ok = send_on_channel0 (Sock , # 'connection.open_ok' {}, Protocol ),
11691170
@@ -1209,6 +1210,16 @@ handle_method0(_Method, #v1{connection_state = S}) ->
12091210 rabbit_misc :protocol_error (
12101211 channel_error , " unexpected method in connection state ~w " , [S ]).
12111212
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+
12121223is_over_connection_limit (VHostPath , User ) ->
12131224 try rabbit_vhost_limit :is_over_connection_limit (VHostPath ) of
12141225 false -> ok ;
@@ -1567,7 +1578,7 @@ maybe_block(State = #v1{connection_state = CS, throttle = Throttle}) ->
15671578 State1 = State # v1 {connection_state = blocked ,
15681579 throttle = update_last_blocked_at (Throttle )},
15691580 case CS of
1570- running ->
1581+ running ->
15711582 ok = rabbit_heartbeat :pause_monitor (State # v1 .heartbeater );
15721583 _ -> ok
15731584 end ,
@@ -1589,7 +1600,7 @@ maybe_send_unblocked(State = #v1{throttle = Throttle}) ->
15891600 case should_send_unblocked (Throttle ) of
15901601 true ->
15911602 ok = send_unblocked (State ),
1592- State # v1 {throttle =
1603+ State # v1 {throttle =
15931604 Throttle # throttle {connection_blocked_message_sent = false }};
15941605 false -> State
15951606 end .
@@ -1598,7 +1609,7 @@ maybe_send_blocked_or_unblocked(State = #v1{throttle = Throttle}) ->
15981609 case should_send_blocked (Throttle ) of
15991610 true ->
16001611 ok = send_blocked (State , blocked_by_message (Throttle )),
1601- State # v1 {throttle =
1612+ State # v1 {throttle =
16021613 Throttle # throttle {connection_blocked_message_sent = true }};
16031614 false -> maybe_send_unblocked (State )
16041615 end .
@@ -1624,7 +1635,7 @@ control_throttle(State = #v1{connection_state = CS,
16241635 running -> maybe_block (State1 );
16251636 % % unblock or re-enable blocking
16261637 blocked -> maybe_block (maybe_unblock (State1 ));
1627- _ -> State1
1638+ _ -> State1
16281639 end .
16291640
16301641augment_connection_log_name (# connection {client_properties = ClientProperties ,
0 commit comments