From fa4f761188f37d99f5bf12c1d0042cb9a8aaef1e Mon Sep 17 00:00:00 2001 From: Jonathan Gazeley <me@jonathangazeley.com> Date: Thu, 26 Feb 2015 11:59:13 +0000 Subject: [PATCH] Add support to freeradius::sql to customise socket lifetimes --- README.md | 10 ++++++++++ manifests/sql.pp | 2 ++ templates/sql.conf.erb | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a03b3ca..124c4c3 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,16 @@ you will see errors like "No connections available and at max connection limit". this to MORE than the number of threads means that there are more connections than necessary. Leave blank to set it to the same value as the number of threads. +##### `lifetime` + +Default: `0`. Lifetime of an SQL socket. If you are having network issues such as TCP sessions expiring, you may need to set the socket +lifetime. If set to non-zero, any open connections will be closed `$lifetime` seconds after they were first opened. + +##### `max_queries` + +Default: `0`. Maximum number of queries used by an SQL socket. If you are having issues with SQL sockets lasting "too long", you can +limit the number of queries performed over one socket. After `$max_qeuries`, the socket will be closed. Use 0 for "no limit". + ##### `query_file` Default: `sql/${database}/dialup.conf`. Relative path to the file which contains your SQL queries. By diff --git a/manifests/sql.pp b/manifests/sql.pp index 1f1be9a..54a24a9 100644 --- a/manifests/sql.pp +++ b/manifests/sql.pp @@ -7,6 +7,8 @@ define freeradius::sql ( $radius_db = 'radius', $num_sql_socks = '${thread[pool].max_servers}', $query_file = 'sql/${database}/dialup.conf', + $lifetime = '0', + $max_queries = '0', $ensure = present, ) { $fr_package = $::freeradius::params::fr_package diff --git a/templates/sql.conf.erb b/templates/sql.conf.erb index b9c5d94..11bce2a 100644 --- a/templates/sql.conf.erb +++ b/templates/sql.conf.erb @@ -92,13 +92,13 @@ sql { # such as TCP sessions expiring, you may need to set the socket # lifetime. If set to non-zero, any open connections will be # closed "lifetime" seconds after they were first opened. - lifetime = 0 + lifetime = <%= @lifetime %> # Maximum number of queries used by an SQL socket. If you are # having issues with SQL sockets lasting "too long", you can # limit the number of queries performed over one socket. After # "max_qeuries", the socket will be closed. Use 0 for "no limit". - max_queries = 0 + max_queries = <%= @max_queries %> # Set to 'yes' to read radius clients from the database ('nas' table) # Clients will ONLY be read on server startup. For performance -- GitLab