Persistent MySQL connections to arbitrary databases

Alexander Clouter alex at digriz.org.uk
Wed Feb 9 11:33:02 CET 2011


Jonathan Gazeley <jonathan.gazeley at bristol.ac.uk> wrote:
>
> I am asking about MySQL connections to a database *other than* the usual 
> radius database.
> 
> For one of my wireless SSIDs, part of the authorization process invokes 
> a perl script which opens a MySQL handle to a different database, does a 
> query, destroys the handle, and returns the value to radiusd.
> 
> There's a lot of overhead in this so I would like to make radiusd open a 
> pool of handles to this database, as it does with its own database.
> 
> What's the approved method for making radiusd open persistent 
> connections to an arbitrary database, and then using these handles from 
> a perl module?
> 
Although I have not tried it for what you want, you should be able to do 
this all in your Perl module in the BEGIN section.  If you 'die' in the 
BEGIN section then freeradius will fail to load which is handy for doing 
some pre-flight checking...which can also include creating a pool of DB 
connections.

However, why do you need to close the handle?  Just when you open it, do 
your work, store it to the side in a hash and mark it available for use 
(remember to add locking as it sounds like your script is threaded).

Cheers

-- 
Alexander Clouter
.sigmonster says: Buck-passing usually turns out to be a boomerang.




More information about the Freeradius-Users mailing list