Problems when calling RT::Init more than once?


I am using RT’s database for general site authentication. For this I wrote
a small Perl Apache handler that I hook to Apache’s authentication phase.

The authentication handler verifies the supplied credentials against RT’s database,
to control access.

I am experiencing problems with the MySQL connection and I wonder if these are
related to the fact that I now call RT::Init more than once during a complete
request cycle (in the Auth phase via my handler and in the main phase via
defined in

Bottom line: does it do any harm to call RT::Init more than once inside a single process?

[Since RT::Init is called inside the handler subroutine in it is called once
per request anyway, so I actually do not see any problems…?]

If anyone can help me out, many thanks in advance.


P.S. Here is the authentication handler’s code just in case someone is interested in
doing a similar thing:

package MyRTAuth;

use strict;
use Apache::Constants qw(:common);

use lib (“/opt/rt3/local/lib”, “/opt/rt3/lib”);
use RT;

RT::Init(); # does this need to go inside the handler routine?

sub handler
my $r = shift;
my ($res,$sent_pw) = $r->get_basic_auth_pw;
return $res if $res != OK;

    my $user = $r->connection->user;

    my $SystemUser = new RT::CurrentUser();

    my $rt_user = RT::User->new($SystemUser);
    my $rv = $rt_user->Load($user);

# does the user exist?
    if($rv eq "Couldn't find row")
            return AUTH_REQUIRED;

# correct password supplied?
    if(! $rt_user->IsPassword($sent_pw) )
            return AUTH_REQUIRED;

    return OK;




AuthName "Site Access" AuthType Basic PerlRequire conf/ PerlAuthenHandler MyRTAuth require valid-user
Jan Algermissen
Consultant & Programmer