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

Commit 157d044

Browse files
committed
Stop emitting stats before hibernate on gen_server2
rabbbitmq-common#196 [#145623415]
1 parent 73f730c commit 157d044

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/gen_server2.erl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ hibernate(GS2State = #gs2_state { timeout_state = TimeoutState }) ->
710710

711711
pre_hibernate(GS2State = #gs2_state { state = State,
712712
mod = Mod }) ->
713+
rabbit_event:stop_stats_timer(GS2State, #gs2_state.timer),
713714
case erlang:function_exported(Mod, handle_pre_hibernate, 1) of
714715
true ->
715716
case catch Mod:handle_pre_hibernate(State) of
@@ -723,16 +724,17 @@ pre_hibernate(GS2State = #gs2_state { state = State,
723724
end.
724725

725726
post_hibernate(GS2State = #gs2_state { state = State,
726-
mod = Mod }) ->
727+
mod = Mod,
728+
init_stats_fun = InitStatsFun }) ->
727729
case erlang:function_exported(Mod, handle_post_hibernate, 1) of
728730
true ->
729731
case catch Mod:handle_post_hibernate(State) of
730732
{noreply, NState} ->
731-
process_next_msg(GS2State #gs2_state { state = NState,
732-
time = infinity });
733+
process_next_msg(InitStatsFun(GS2State #gs2_state { state = NState,
734+
time = infinity }));
733735
{noreply, NState, Time} ->
734-
process_next_msg(GS2State #gs2_state { state = NState,
735-
time = Time });
736+
process_next_msg(InitStatsFun(GS2State #gs2_state { state = NState,
737+
time = Time }));
736738
Reply ->
737739
handle_common_termination(Reply, post_hibernate, GS2State)
738740
end;
@@ -743,7 +745,7 @@ post_hibernate(GS2State = #gs2_state { state = State,
743745
%% still set to hibernate, iff that msg is the very msg
744746
%% that woke us up (or the first msg we receive after
745747
%% waking up).
746-
process_next_msg(GS2State #gs2_state { time = hibernate })
748+
process_next_msg(InitStatsFun(GS2State #gs2_state { time = hibernate }))
747749
end.
748750

749751
adjust_timeout_state(SleptAt, AwokeAt, {backoff, CurrentTO, MinimumTO,

0 commit comments

Comments
 (0)