I have a script that runs under modperl very well. It consists of one main
executable CGI file, and it 'requires' a few other pieces of source code.
One of the files it requires is called db.pl. This file creates a package,
and it contains several 'global' variables for that package (database name,
username, password). There is a function in that package that is called to
establish a connection to the db server, and in doing so it creates a global
database handle.

This is where things get interesting. I want to run two seperate instances
of the script on the same server. So I made a new directory for the second
instance and made another copy of the source in the new dir. In this new
instance of the db.pl file I changed the database name, username, and
password... I made sure that this new script only requires files from its
new directory (not the old one that I copied it from, and where the other
instance will live).

When I use the script from the web, it seems to work great. Both instances
of the program use their own database and all is well. However after some
time passes it seems that one of the scripts will start 'using' the other
scripts database handle. I inserted some debug statements into the files and
I was able to determine that when script A calls the db connection function
sometimes script B's db connect function is called. Keep in mind the db
connection files are distinct files in seperate directories. The only thing
they have in common is the same filename (neglecting path) and same package
name.

I suspect that modperl may be trying to use a precompiled version of db.pl
when my script runs, and it isnt distuinguishing between the different files
(or maybe it isnt distinguishing between the packages since they have the
same name?). Or even, when my script accesses $Packagename::dbh as a global
variable inside the Packagename package, only one such varaible exists
within that perl instance inside Apache (even though there should be two).

Does anyone who knows more about the internal of modperl have ideas as to
what is going on? Ive checked and double checked my code to make sure it was
including the right files and not getting them confused, and Im fairly
certain that something fishy is going on with modperl. Any help or guidance
would be apreicaited!!

Thanks,
ryan

Reply via email to