diff --git a/src/ergw_aaa_session.erl b/src/ergw_aaa_session.erl index b014339..0f00bc6 100644 --- a/src/ergw_aaa_session.erl +++ b/src/ergw_aaa_session.erl @@ -80,9 +80,7 @@ event(Session, Event, EvOpts, SessionOpts) when is_map(SessionOpts) -> %%=================================================================== start_link(Owner, SessionData) -> - Opts = [{hibernate_after, 500}, - {spawn_opt,[{fullsweep_after, 0}]}], - gen_statem:start_link(?MODULE, [Owner, SessionData], Opts). + proc_lib:start_link(?MODULE, init, [[Owner, SessionData]], infinity, [{fullsweep_after, 0}]). invoke_compat_async(Session, SessionOpts, Procedure) -> case invoke(Session, SessionOpts, Procedure, #{async => true}) of @@ -170,6 +168,7 @@ callback_mode() -> handle_event_function. init([Owner, SessionOpts]) -> process_flag(trap_exit, true), + proc_lib:init_ack({ok, self()}), AppId = maps:get('AAA-Application-Id', SessionOpts, default), SessionId = ergw_aaa_session_seq:inc(AppId), @@ -190,7 +189,7 @@ init([Owner, SessionOpts]) -> ergw_aaa_session_reg:register(SessionId), ergw_aaa_session_reg:register(DiamSessionId), - Data = #data{ + Data0 = #data{ owner = Owner, owner_monitor = MonRef, application = AppId, @@ -198,8 +197,8 @@ init([Owner, SessionOpts]) -> session = DefaultSessionOpts }, State = #state{}, - {Reply, DataOut, _Events} = exec(init, SessionOpts, #{}, Data), - {Reply, State, DataOut}. + {ok, Data, _Events} = exec(init, SessionOpts, #{}, Data0), + gen_statem:enter_loop(?MODULE, [{hibernate_after, 500}], State, Data). handle_event({call, From}, get, _State, Data) -> {keep_state_and_data, [{reply, From, Data#data.session}]}; diff --git a/test/diameter_Gy_SUITE.erl b/test/diameter_Gy_SUITE.erl index 64002e1..be847d0 100644 --- a/test/diameter_Gy_SUITE.erl +++ b/test/diameter_Gy_SUITE.erl @@ -64,7 +64,7 @@ -define(CONFIG, #{rate_limits => - #{default => #{outstanding_requests => 1, rate => 10}}, + #{default => #{outstanding_requests => 10, rate => 10}}, functions => ?DIAMETER_FUNCTION, handlers => #{ergw_aaa_static => ?STATIC_CONFIG, @@ -602,7 +602,7 @@ rate_limit(_Config) -> CCRt = CollectFun('CCR-Terminate', SRefs, #{}), %% make sure to refill the token buckets, so that the following tests don't fail - ct:sleep(1100), + ct:sleep(2500), ?match(#{ok := OkayI, {error,rate_limit} := LimitI} when OkayI >= 40 andalso