@@ -708,8 +708,9 @@ hibernate(GS2State = #gs2_state { timeout_state = TimeoutState }) ->
708
708
proc_lib :hibernate (? MODULE , wake_hib ,
709
709
[GS2State # gs2_state { timeout_state = TS }]).
710
710
711
- pre_hibernate (GS2State = # gs2_state { state = State ,
712
- mod = Mod }) ->
711
+ pre_hibernate (GS2State0 = # gs2_state { state = State ,
712
+ mod = Mod }) ->
713
+ GS2State = maybe_stop_stats (GS2State0 ),
713
714
case erlang :function_exported (Mod , handle_pre_hibernate , 1 ) of
714
715
true ->
715
716
case catch Mod :handle_pre_hibernate (State ) of
@@ -722,8 +723,10 @@ pre_hibernate(GS2State = #gs2_state { state = State,
722
723
hibernate (GS2State )
723
724
end .
724
725
725
- post_hibernate (GS2State = # gs2_state { state = State ,
726
- mod = Mod }) ->
726
+ post_hibernate (GS2State0 = # gs2_state { state = State ,
727
+ mod = Mod ,
728
+ init_stats_fun = InitStatsFun }) ->
729
+ GS2State = InitStatsFun (GS2State0 ),
727
730
case erlang :function_exported (Mod , handle_post_hibernate , 1 ) of
728
731
true ->
729
732
case catch Mod :handle_post_hibernate (State ) of
@@ -1381,5 +1384,10 @@ emit_stats(GS2State = #gs2_state{queue = Queue}) ->
1381
1384
# gs2_state .timer , emit_gen_server2_stats ).
1382
1385
1383
1386
stop_stats (GS2State ) ->
1384
- _ = rabbit_event : stop_stats_timer (GS2State , # gs2_state . timer ),
1387
+ maybe_stop_stats (GS2State ),
1385
1388
rabbit_core_metrics :gen_server2_deleted (self ()).
1389
+
1390
+ maybe_stop_stats (# gs2_state {timer = undefined } = GS2State ) ->
1391
+ GS2State ;
1392
+ maybe_stop_stats (GS2State ) ->
1393
+ rabbit_event :stop_stats_timer (GS2State , # gs2_state .timer ).
0 commit comments