(RADIATOR) PostAuthHook and DB connection

Frank Danielson fdanielson at csky.com
Fri Sep 26 07:09:17 CDT 2003


You can use an existing database handle from an AuthBy SQL or SessSQL in
your hook. This not only reduces the overhead of disconnecting and
reconnecting to the db each time but also lets you leverage the work that
Radiator does behing the scenes to manage the db connection.   Here is an
excerpt from a post by Hugh to the mailing list that explains the details.
The original message can be found here ->
http://www.open.com.au/archives/radiator/2000-06/msg00023.html

I use this technique in several hooks and it works just dandy.

............................................................................
.....
# configuration to allow a PostAuthHook to access a database
# either define a new AuthBy SQL if different to an existing AuthBy SQL
# or add an Identifier tag to your existing AuthBy SQL

<AuthBy SQL>
	Identifier yourSQL
	DBSource ....
	DBUsername ....
	DBAuth ....
</AuthBy>


Then in your hook use the find function in AuthGeneric to retrieve the
reference
to that AuthBy SQL. Once you have the reference, you can use all the
standard
routines in AuthSQL.pm and SqlDb.pm, including prepareAndExecute, etc.

# hook to use an SQL database

sub
{
    my $p = ${$_[0]};
    my $rp = ${$_[1]};
    my $result = ${$_[2]};

    my $authby_handle = Radius::AuthGeneric::find('yourSQL');
    my $query = "select ......";
    my $sth = $authby_handle->prepareAndExecute($query);
    .....
}

This way you avoid most of the housekeeping, as it is already taken care of
by
the routines in SqlDb.pm. As a relatively simple example of some SQL code
that
uses these routines, have a look at Radius/SessSQL.pm.
............................................................................
........

Frank Danielson
[Infrastructure Architect]

voice:407.515.8633
fax:407.515.9001

ClearSky Mobile Media, Inc.
56 E. Pine St. Suite 200
Orlando, FL 32801
USA
 
-----Original Message-----
From: S H A N [mailto:shanali at magix.com.sg]
Sent: Friday, September 26, 2003 6:45 AM
To: radiator at open.com.au
Subject: (RADIATOR) PostAuthHook and DB connection


hi,
	i am trying to think of a method where i can avoid 

	connect to db
		do something...
	disconnect from db

	each time one of my hook gets processing in a radius operation for
each
	postauth request. (so if it handles 100k packets it means that i
does
	100k times connect to db and 100k times of disconnect!)

	ideally i want..

	to connect to db... (at the point of startup of radius)

		keep on doing something without disconnecting/connecting
again
	        till the life of the radius session/process.

	any suggestions?
	
S H A N
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list