You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jie Gao <J....@isu.usyd.edu.au> on 2001/02/10 04:54:28 UTC

Re: PerlRun problem: undefined variables (Was: can't find method "uri")

On Thu, 11 Jan 2001, Doug MacEachern wrote:

> On Thu, 4 Jan 2001, Jie Gao wrote:
>  
> > Another problem with PerlRun is that it seems to interfere with mod_perl
> > handlers.
> > 
> > I have an authentication/authorisation handler, which reads in from a
> > file for someinformation. After a script under PerlRun is run, the handler
> > fails to read anything from that file anymore.
> 
> i can't see what's happening from this, too much missing.  can you provide
> a small, but complete drop-in test case?

Sorry for this late reply, Doug. Here are some details.

This is from my authentication handler, which gets the location of a
file from a PerlSetVar directive, and then opens the file and reads
username and password into the variables to be used for database
connection:

---------------------------------------------------------------------------
    my ($dsf, $db_f_name, $db_user_name, $db_user_pwd, $ds_name, $AuthenQueryValue);
    # Get the db data source file.
    $dsf = $r->dir_config( 'DSF' );
    if (!defined $dsf || $dsf eq '') {
        $r->log_error("DSF not defined.") if ($debug > 3);
        return SERVER_ERROR;
    }

    # Get the db server login info.
    if (defined $dsf) {
        open(DBCONF, "$dsf") || $r->log_error("Can't open DSF file $dsf:$!");
        while(<DBCONF>){
            next if /^#/;
            next unless /^$ds_name:/;
            chomp;
            ($ds_name, $db_f_name, $db_user_name, $db_user_pwd) = split(':', $_);
            $r->log_error("In loop: ds_name=\"$ds_name\", db_f_name=\"$db_f_name\", db_user_name=\"$db_user_name\
", db_user_pwd=\"$db_user_pwd\"\n") if ($debug > 3);
            last;
        }
        close DBCONF;
    } else {
        $r->log_reason("DB source file not defined.") if ($debug > 3);
        return SERVER_ERROR;
    }

    unless (defined $db_f_name && defined $db_user_name && defined $db_user_pwd) {
        $r->log_reason("DB source file error: definition incomplete: db_f_name=\"$db_f_name\"; db_user_name=\"$db
_user_name\"; db_user_pwd=\"$db_user_pwd\".") if ($debug > 3);
        return SERVER_ERROR;
    }
---------------------------------------------------------------------------

Now from time to time these variables become undefined, as shown in the error_log:

[Sat Feb 10 12:30:13 2001] [error] access to / failed for 129.xx.xx.xx, reason: DB source file error: definition
incomplete: db_f_name=""; db_user_name=""; db_user_pwd="".

This happens with 1.25 as well.

Hardcoding the variables prevents this from happening.

Regards,



Jie