# closed "lifetime" seconds after they were first opened.
lifetime = 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".
+ max_queries = 0
# Set to 'yes' to read radius clients from the database ('nas' table)
# Clients will ONLY be read on server startup. For performance
int deletestalesessions;
int num_sql_socks;
int lifetime;
+ int max_queries;
int connect_failure_retry_delay;
char *postauth_query;
char *allowed_chars;
offsetof(SQL_CONFIG,num_sql_socks), NULL, "5"},
{"lifetime", PW_TYPE_INTEGER,
offsetof(SQL_CONFIG,lifetime), NULL, "0"},
+ {"max_queries", PW_TYPE_INTEGER,
+ offsetof(SQL_CONFIG,max_queries), NULL, "0"},
{"sql_user_name", PW_TYPE_STRING_PTR,
offsetof(SQL_CONFIG,query_user), NULL, ""},
{"default_user_profile", PW_TYPE_STRING_PTR,
void *conn;
SQL_ROW row;
time_t connected;
+ int queries;
} SQLSOCK;
typedef struct rlm_sql_module_t {
inst->config->xlat_name, sqlsocket->id);
sqlsocket->state = sockconnected;
if (inst->config->lifetime) time(&sqlsocket->connected);
+ sqlsocket->queries = 0;
return(0);
}
}
/*
+ * If we have performed too many queries over this
+ * socket, then close it.
+ */
+ if (inst->config->max_queries && (cur->state == sockconnected) &&
+ (cur->queries >= inst->config->max_queries)) {
+ (inst->module->sql_close)(cur, inst->config);
+ cur->state = sockunconnected;
+ goto reconnect;
+ }
+
+ /*
* If we happen upon an unconnected socket, and
* this instance's grace period on
* (re)connecting has expired, then try to
* as it's a pointer only used for reading.
*/
inst->last_used = cur->next;
+ cur->queries++;
return cur;
/* move along the list */