A promising new turn...
In the main Noosphere module in the subroutine handler, I've replaced the connection condition block to just a simple connection. So ~ line 430 I replaced
unless ($dbh ||= dbConnect()) {
die "Couldn't open database: ",$DBI::errstr;
}
with just
$dbh = dbConnect();
I'm really not sure what ||= is suppose to do, maybe I need to test a similar expression. The following test was made
#!/usr/bin/perl
$test = -1;
unless ($test ||= connect1())
{ die "Die connect1";
}
print "After connect1\n";
print ("$test\n");
$test = -2;
unless ($test ||= connect2())
{ die "Die connect2";
}
print "After connect2\n";
print ("$test\n");
sub connect1()
{
return 1;
}
sub connect2()
{
return 0;
}
The output of running the above perl script is:
After connect1
-1
After connect2
-2
So we observe a few things. The unless statement always evaluates false. If $test is initialized to 1 then the die statement is printed.
- so what seems to happen is that an OR is evaluated on $test and on = Connect1. So if $dbh is true before the statement (so database handle is still true?) then it dies
- what is interesting is that it does not matter what connect returns, it always evaluates to false so this statement completely depends on $dbh
I'm not sure if this is the intended behavior or if it has anything to do with losing the connection with the database. I need some feedback from someone with perl wisdom. However, it seems very promising that the database connection stays 'on'.
In the main Noosphere module in the subroutine handler, I've replaced the connection condition block to just a simple connection. So ~ line 430 I replaced
unless ($dbh ||= dbConnect()) {
die "Couldn't open database: ",$DBI::errstr;
}
with just
$dbh = dbConnect();
I'm really not sure what ||= is suppose to do, maybe I need to test a similar expression. The following test was made
#!/usr/bin/perl
$test = -1;
unless ($test ||= connect1())
{ die "Die connect1";
}
print "After connect1\n";
print ("$test\n");
$test = -2;
unless ($test ||= connect2())
{ die "Die connect2";
}
print "After connect2\n";
print ("$test\n");
sub connect1()
{
return 1;
}
sub connect2()
{
return 0;
}
The output of running the above perl script is:
After connect1
-1
After connect2
-2
So we observe a few things. The unless statement always evaluates false. If $test is initialized to 1 then the die statement is printed.
- so what seems to happen is that an OR is evaluated on $test and on = Connect1. So if $dbh is true before the statement (so database handle is still true?) then it dies
- what is interesting is that it does not matter what connect returns, it always evaluates to false so this statement completely depends on $dbh
I'm not sure if this is the intended behavior or if it has anything to do with losing the connection with the database. I need some feedback from someone with perl wisdom. However, it seems very promising that the database connection stays 'on'.