httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Robert S. Thau)
Subject Re: letting modules specify startup code
Date Mon, 19 Feb 1996 16:59:53 GMT
Hmmm... if the database access library doesn't get confused when
clients fork(), you could use an ordinary module setup routine (i.e.,
open the database connection at the same time log files, etc., are
opened).  NB that for this to work, Oracle has to stay unconfused when
multiple clients make simultaneous requests over the same connection.

If not, then you could try something along these lines:

   static int have_db_connection = 0;
   static DB_CONNECTION_DATA ...;

   int my_authenticate_basic_user (request_rec *r)

      if (!have_db_connection) { the connection...

         have_db_connection = 1;

      ... use the database ...

If global variables are *really* anathema to you, you could try hiding
the have_connection variable and the associated per-connection data in
module per-server state, but that would involve opening a separate
database connection for each virtual host, which would probably be
prohibitive in configurations which have large numbers of 'em.

[Note that with this solution, the database must be prepared to have
clients die between transactions without losing its own cookies ---
so long as this applies, you don't have to worry about reopening the
connection on SIGHUP, since it is only opened in child processes 
which are killed before the config files are reread].


PS --- sorry if this does seem a bit hackish, but I *think* it ought
   to work.

View raw message