undefined subroutine.....called at /dev/null line 21

2000-10-14 Thread Christopher Lee

Hi,

Im running apache1.3.12/modperl1.24 (static compiled) on redhat6 and I'm 
getting some strange errors like above, I also get:

-
Database handler destroyed withouth explicit disconnect at /dev/null line 21
-

and I get both errors without the /dev/null bit on the end!

I'm sure this bug is in my perl code, but (you saw that coming, right? :) 
 I only get this bug either

1. on every other restart of httpd, sometimes depending on the first url
   requested

or 2. every other request to the same url

or 3. for the first X calls to the server then every other request!

all three server_errors occur with the same code, which confuses me 
more than the /dev/null error. I'm thinking this is a config error, but I have
no idea why...

The config and code...(abridged version, the full version can be 
temporarily found at http://compsoc.net/~chris/modperl.html if necessary)


ServerType standalone
ServerRoot "/usr/local/apache"
Timeout 30
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 1
MaxSpareServers 20
StartServers 1
MaxClients 40
MaxRequestsPerChild 100
PerlRequire conf/BV.pl
   
SetHandler perl-script
perlhandler BV


SetHandler perl-script
perlhandler BV::Login


SetHandler perl-script
perlhandler BV::LoginScreen

DocumentRoot /home/chris/system/public_html

--
package BV;

use Apache::Constants qw/:common/;
use BV::Config;
use BV::Common;
use DBI;
use strict;
use vars qw($BV_CONF);

sub handler {
my $r=shift;

if (!$r) 
{
Apache->error("undefined request passed to BV::handler");
return OK;
}

my $V=bless {r=>$r},"BV";
my @args;

($V->{Location}, $V->{Handler}, $V->{Username}, $V->{UrlSession}, $V->{Command},@args) 
= split(m(/),$r->path_info);

$V->{args}=\@args;

if($V->{Handler} eq "kill")
{
$V->kill_login($V->{UrlSession});
return OK;
}


$V->{UrlPrefix}=$BV_CONF->{DomainName}.
$BV_CONF->{Location}.
$BV_CONF->{Handler};
$V->{UrlPrefix}.=$V->{Username};


$V->{ip}=$r->connection->remote_ip;
$V->{Session}=check_cookie($V->{r});

($V->{dbh}=DBI->connect($BV_CONF->{DatabaseName},$BV_CONF->{DatabaseUser},$BV_CONF->{DatabasePass}))
 or return undef;

if(!defined($V->{Session})) 
{
$V->{Session}=$V->{UrlSession};
$V->{UrlPrefix}=$V->{Session};
}

else {$V->{UrlPrefix}.="x"; }

if($V->{Command} eq "session") 
{return redirect($V->{r},"$V->{UrlPrefix}"."/top"); }


dont_cache($r,"text/html");
$V->{r}->print("test test test");
$V->{dbh}->disconnect;
return OK;
}

sub kill_login{
my ($V,$s) = @_;
my $u=$V->{Username};
my $dbh;
if(!($dbh=DBI->connect($BV_CONF->{DatabaseName},$BV_CONF->{DatabaseUser},$BV_CONF->{DatabasePass})))
{
Log("No handle in kill_login");
return undef;
}

$dbh->do("DELETE FROM sessions WHERE username='$u' AND session_id='$s'");
Log("DELETE FROM sessions WHERE username=$u AND session_id=$s");
$dbh->disconnect;
redirect($V->{r},"$BV_CONF->{DomainName}$BV_CONF->{LoginScreenUrl}");
}

1;


There is more but I'll spare you the download just in case...

please help.I'm going mad...
--

Christopher Lee.

http://compsoc.net/~chris




Re: Apache::Dispatch

2000-06-05 Thread Christopher Lee

> [new module] Apache::Dispatch
>   5129 by: Geoffrey Young <[EMAIL PROTECTED]>
>   5131 by: Stas Bekman <[EMAIL PROTECTED]>
>   5132 by: Matt Sergeant <[EMAIL PROTECTED]>
>   5133 by: Geoffrey Young <[EMAIL PROTECTED]>
>   5134 by: Geoffrey Young <[EMAIL PROTECTED]>

There's a real live working example if anybody wants it, called "Wing", 
available from your local friendly CPAN.

The module is used as an IMAP interface but the main module handles everything
except logins, the url is used to pass commands around, the one I'm looking at
at the moment is

http://server1.herald.ox.ac.uk/wing/cmd/ball/x/compose

The "wing/cmd" tells the module that this is a call for the function called 
(in this case) "cmd_compose" with the parameters "ball" (a username) 
(x is a dummy used for other functions I think).

Internally the module takes 'compose' and prefixes it with 'cmd_', evals the
string as a soft reference to a function and returns an error code if the function
doesn't exist, or runs the function if it does.

It only lets a strict subset of functions run (it always appends a "cmd_" to 
the name) so internal functions are safe .

It was created by Malcolm Beattie (i.e Not me).

--
Christopher Lee.
(I'm only on the Digest list btw).


>hi all...
>
>I'm not sure if some you remember the idea Vivek and Matt had about creating
>a handler that mapped, say, http://localhost/Foo/doit to Foo->doit()
>
>anyway, the relevant part of the thread, including some code, can be seen
>here:
>http://marc.theaimsgroup.com/?l=apache-modperl&m=95598609306936&w=2
>
>I was thinking of officially implementing the idea and wanted to get some
>design feedback first...
>
>My thoughts so far:
>
>* limit the response to content handling phase only (I'm not really
>sure of what utility other phases would be anyway)
>
>* limit the top-level qualifier for the module that can be executed,
>but give this control to the user.
>  perhaps using PerlAddVar to allow only Apache::, Foo::, etc
>modules only is safe enough?
>
>* if possible, I'd like to see it make some intelligent decisions
>about whether it should take over the request.
>  that is, perhaps move away from a  restriction and try
>to call Foo->doit() if the normal resoltion  /Foo/doit results in a 404.
>I'm not sure how this would interact with mod_dir, but I guess it would also
>depend on how folks want to use it...
>
>   * do we want to default to handler()?  if so, what to try first:
>Foo::doit->handler() or Foo->doit()
>
>anyway, that's all for now...  feedback/thoughts welcome...

--Geoff

--