Skip to content

Commit f41fd14

Browse files
committed
WIP: pre/post_hibernate
1 parent 5a86545 commit f41fd14

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

deps/rabbit/src/rabbit_channel.erl

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -745,20 +745,20 @@ handle_info({update_user_state, User}, State = #ch{cfg = Cfg}) ->
745745
noreply(State#ch{cfg = Cfg#conf{user = User}}).
746746

747747

748-
handle_pre_hibernate(State0) ->
749-
ok = clear_permission_cache(),
750-
State = maybe_cancel_tick_timer(State0),
751-
rabbit_event:if_enabled(
752-
State, #ch.stats_timer,
753-
fun () -> emit_stats(State,
754-
[{idle_since,
755-
os:system_time(millisecond)}])
756-
end),
757-
{hibernate, rabbit_event:stop_stats_timer(State, #ch.stats_timer)}.
758-
759-
handle_post_hibernate(State0) ->
760-
State = init_tick_timer(State0),
761-
{noreply, State}.
748+
%handle_pre_hibernate(State0) ->
749+
% ok = clear_permission_cache(),
750+
% State = maybe_cancel_tick_timer(State0),
751+
% rabbit_event:if_enabled(
752+
% State, #ch.stats_timer,
753+
% fun () -> emit_stats(State,
754+
% [{idle_since,
755+
% os:system_time(millisecond)}])
756+
% end),
757+
% {hibernate, rabbit_event:stop_stats_timer(State, #ch.stats_timer)}.
758+
%
759+
%handle_post_hibernate(State0) ->
760+
% State = init_tick_timer(State0),
761+
% {noreply, State}.
762762

763763
terminate(_Reason,
764764
State = #ch{cfg = #conf{user = #user{username = Username}},
@@ -2640,20 +2640,20 @@ init_tick_timer(State) ->
26402640
reset_tick_timer(State) ->
26412641
State#ch{tick_timer = undefined}.
26422642

2643-
maybe_cancel_tick_timer(#ch{tick_timer = undefined} = State) ->
2644-
State;
2645-
maybe_cancel_tick_timer(#ch{tick_timer = TRef,
2646-
unacked_message_q = UMQ} = State) ->
2647-
case ?QUEUE:len(UMQ) of
2648-
0 ->
2649-
%% we can only cancel the tick timer if the unacked messages
2650-
%% queue is empty.
2651-
_ = erlang:cancel_timer(TRef),
2652-
State#ch{tick_timer = undefined};
2653-
_ ->
2654-
%% let the timer continue
2655-
State
2656-
end.
2643+
%maybe_cancel_tick_timer(#ch{tick_timer = undefined} = State) ->
2644+
% State;
2645+
%maybe_cancel_tick_timer(#ch{tick_timer = TRef,
2646+
% unacked_message_q = UMQ} = State) ->
2647+
% case ?QUEUE:len(UMQ) of
2648+
% 0 ->
2649+
% %% we can only cancel the tick timer if the unacked messages
2650+
% %% queue is empty.
2651+
% _ = erlang:cancel_timer(TRef),
2652+
% State#ch{tick_timer = undefined};
2653+
% _ ->
2654+
% %% let the timer continue
2655+
% State
2656+
% end.
26572657

26582658
now_millis() ->
26592659
erlang:monotonic_time(millisecond).

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy