@@ -2256,7 +2256,7 @@ loop(ServerData, State, {continue, Continue} = Msg, Debug) ->
2256
2256
loop (ServerData , State , LoopAction , Debug ) ->
2257
2257
case LoopAction of
2258
2258
{timeout_zero , TimeoutMsg } ->
2259
- decode_msg (ServerData , State , TimeoutMsg , Debug , [], false );
2259
+ decode_msg (ServerData , State , infinity , Debug , [], TimeoutMsg );
2260
2260
{timeout , Timer , HibInf } ->
2261
2261
loop (ServerData , State , HibInf , Debug , Timer );
2262
2262
HibT ->
@@ -2267,46 +2267,39 @@ loop(ServerData, State, hibernate, Debug, Timer) ->
2267
2267
receive
2268
2268
Msg ->
2269
2269
erlang :garbage_collect (),
2270
- decode_msg (ServerData , State , Msg , Debug , Timer , true )
2270
+ decode_msg (ServerData , State , hibernate , Debug , Timer , Msg )
2271
2271
after 0 ->
2272
- loop_hibernate (ServerData , State , Debug , Timer )
2272
+ loop_hibernate (ServerData , State , Timer , Debug )
2273
2273
end ;
2274
2274
% %
2275
- loop (# server_data { hibernate_after = HibernateAfterTimeout } = ServerData , State , infinity , Debug , Timer ) ->
2275
+ loop (ServerData , State , infinity , Debug , Timer ) ->
2276
2276
receive
2277
2277
Msg ->
2278
- decode_msg (ServerData , State , Msg , Debug , Timer , false )
2279
- after HibernateAfterTimeout ->
2280
- loop_hibernate (ServerData , State , Debug , Timer )
2278
+ decode_msg (ServerData , State , infinity , Debug , Timer , Msg )
2279
+ after ServerData # server_data . hibernate_after ->
2280
+ loop_hibernate (ServerData , State , Timer , Debug )
2281
2281
end ;
2282
2282
% %
2283
2283
loop (ServerData , State , Time , Debug , Timer )
2284
2284
when ? is_rel_timeout (Time ) ->
2285
- Msg = receive
2286
- Input ->
2287
- Input
2288
- after Time ->
2289
- timeout
2290
- end ,
2291
- decode_msg (ServerData , State , Msg , Debug , Timer , false ).
2292
-
2293
- loop_hibernate (ServerData , State , Debug , Timer ) ->
2285
+ receive
2286
+ Msg ->
2287
+ decode_msg (ServerData , State , Time , Debug , Timer , Msg )
2288
+ after Time ->
2289
+ decode_msg (ServerData , State , infinity , Debug , Timer , timeout )
2290
+ end .
2291
+
2292
+ loop_hibernate (ServerData , State , Timer , Debug ) ->
2294
2293
erlang :hibernate (),
2295
- loop_wakeup (ServerData , State , Debug , Timer ).
2294
+ loop_wakeup (ServerData , State , Timer , Debug ).
2296
2295
2297
- loop_wakeup (ServerData , State , Debug , Timer ) ->
2296
+ loop_wakeup (ServerData , State , Timer , Debug ) ->
2298
2297
receive
2299
2298
Msg ->
2300
- decode_msg (update_callback_cache (ServerData ), State , Msg , Debug , Timer , true )
2299
+ decode_msg (
2300
+ update_callback_cache (ServerData ), State , hibernate , Debug , Timer , Msg )
2301
2301
end .
2302
2302
2303
- loop_continue (ServerData , State , Hib , Debug , Timer ) ->
2304
- Action = case Hib of
2305
- true -> hibernate ;
2306
- false -> infinity
2307
- end ,
2308
- loop (ServerData , State , Action , Debug , Timer ).
2309
-
2310
2303
cancel_timer ([]) ->
2311
2304
ok ;
2312
2305
cancel_timer ([TRef | _ ]) ->
@@ -2332,17 +2325,17 @@ update_callback_cache(#server_data{module = Mod} = ServerData) ->
2332
2325
handle_info = fun Mod :handle_info /2 ,
2333
2326
handle_continue = fun Mod :handle_continue /2 }.
2334
2327
2335
- decode_msg (# server_data {parent = Parent , tag = Tag } = ServerData , State , Msg , Debug , Timer , Hib ) ->
2328
+ decode_msg (# server_data {parent = Parent , tag = Tag } = ServerData , State , HibT , Debug , Timer , Msg ) ->
2336
2329
case Msg of
2337
2330
{system , From , Req } ->
2338
2331
sys :handle_system_msg (Req , From , Parent , ? MODULE , Debug ,
2339
- [ServerData , State , Timer , Hib ], Hib );
2332
+ [ServerData , State , HibT , Timer ], HibT =:= hibernate );
2340
2333
{'EXIT' , Parent , Reason } ->
2341
2334
terminate (ServerData , State , Msg , undefined , Reason , ? STACKTRACE (), Debug );
2342
2335
{timeout , TRef , Tag } when TRef =:= hd (Timer ) ->
2343
2336
decode_msg (ServerData , State , tl (Timer ), Debug );
2344
2337
{timeout , _Stale , Tag } ->
2345
- loop_continue (ServerData , State , Hib , Debug , Timer );
2338
+ loop (ServerData , State , HibT , Debug , Timer );
2346
2339
_ ->
2347
2340
cancel_timer (Timer ),
2348
2341
decode_msg (ServerData , State , Msg , Debug )
@@ -2613,8 +2606,9 @@ listify(Opt) ->
2613
2606
% % Callback functions for system messages handling.
2614
2607
% %-----------------------------------------------------------------
2615
2608
-doc false .
2616
- system_continue (Parent , Debug , [# server_data {parent = Parent } = ServerData , State , Timer , Hib ]) ->
2617
- loop_continue (update_callback_cache (ServerData ), State , Hib , Debug , Timer ).
2609
+ system_continue (
2610
+ Parent , Debug , [# server_data {parent = Parent } = ServerData , State , HibT , Timer ]) ->
2611
+ loop (update_callback_cache (ServerData ), State , HibT , Debug , Timer ).
2618
2612
2619
2613
-doc false .
2620
2614
-spec system_terminate (_ , _ , _ , [_ ]) -> no_return ().
0 commit comments