From cbbfc453d31c800bbf22f82d8d6254ebe448b5ad Mon Sep 17 00:00:00 2001 From: Artem Teslenko Date: Sun, 13 Feb 2011 04:53:12 -0500 Subject: [PATCH] Disconnect clients in case of application shutdown --- README.md | 5 ++++- src/iptraffic_session.erl | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51b78cd..1efdd81 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,16 @@ Configuration The following modules should be added to the netspire.conf file: - {mod_iptraffic, [{tariffs, "tariffs.conf"}, {session_timeout, 60}, {delay_stop, 5}]} + {mod_iptraffic, [{tariffs, "tariffs.conf"}, {session_timeout, 60}, {delay_stop, 5}, {disconnect_on_shutdown, yes}]} The default value of the **session_timeout** option is 60 seconds and may be ommited. The ***delay_stop*** option is used to delay stopping of the session to receive all data from netflow sensor after the session closing (After receiving Accounting-Stop packet). The default value of the ***delay_stop*** option is 5 seconds and and may be ommited. +The ***disconnect_on_shutdown*** option is used to specify is need to disconnect clients from NAS in case of application shutdown. +The default value of the ***disconnect_on_shutdown*** option is yes and may be ommited. + You MUST set **Acct-Interim-Interval** RADIUS attribute for client. This attribute is required to prolong session and it's value MUST be significantly less than **session_timeout**. Note that if Netspire does not receiving interim updates from NAS via RADIUS, sessions will be marked as *expired* and closed, regardless of real state on NAS. diff --git a/src/iptraffic_session.erl b/src/iptraffic_session.erl index 38d3418..4564f44 100644 --- a/src/iptraffic_session.erl +++ b/src/iptraffic_session.erl @@ -174,6 +174,11 @@ code_change(_OldVsn, State, _Extra) -> terminate(normal, State) -> ?INFO_MSG("Session ~s finished successfully~n", [to_string(State)]); terminate(shutdown, State) -> + case gen_module:get_option(mod_iptraffic, disconnect_on_shutdown, yes) of + yes -> + disconnect_client(State); + _ -> ok + end, stop_session(State, false), ?INFO_MSG("Session ~s shutted down successfully~n", [to_string(State)]); terminate(Reason, State) ->