thread trouble

From: Alexandre Jaquet (alexj_at_floor.ch)
Date: 02/28/05


Date: Mon, 28 Feb 2005 11:47:24 +0100

Hi I could not understant why I got the following error message :

This Perl has neither ithreads nor 5005threads at
/usr/local/lib/perl5/5.8.6/Thread.pm line 335
BEGIN failed--compilation aborted at
/usr/local/lib/perl5/5.8.6/Thread.pm line 335.
Compilation failed in require at close_session.pl line 4.

with the following piece of code :

#!/usr/bin/perl -w
use strict;
use DBI;
use Thread;

my $db_user = 'dbmaster';
my $db_password = 'xxx';
my $db_host = '192.168.123.90';
my $dbh = connectToServer ($db_host,$db_user, $db_password);
my @dbs = getDatabases ();

sub connectToServer {
     warn "Connection to server ..\n";
     my $dbname = shift || '';
     my $dbusername = shift || '';
     my $dbpassword = shift || '';
     $dbh = DBI->connect($db_host, $dbusername, $dbpassword);
     if (!$dbh) {
        warn("DBI: !! Unable to connect to dbname:$dbusername...");
     }
      else {
             print "connected";
        }
      kill 9, $$ unless $dbh;
    return \$dbh;
}

sub getDatabases {
     warn "Get databases ...";
     my @dbs = ();
     my ($c)=$dbh->prepare("SHOW DATABASES") or
             die "Sql has gone to hell\n";
     if(not ($c->execute())) {
        my $err=$dbh->errstr;
        return undef;
        }
     (@dbs)=$c->fetchrow();
      $c->finish();
     return @dbs;
}

sub closeSessions {
   warn "close sessions";
   Thread->new(\&execute())->join() foreach @dbs;
}

sub execute {
     my $db = shift || '';
     warn $db ." current \n";
     my $dbh = DBI->connect($db, $db_user, $db_password);
     if (!$dbh->do("UPDATE sessionlist SET status='lost' WHERE moddate <
                DATE_SUB(NOW() , '60 Minute' AND status='open'")) {
     my $err=$dbh->errstr;
  }
}

thx in advance



Relevant Pages

  • [tip:perf/scripting] perf trace: Add perf trace scripting support modules for Perl
    ... Add Perf-Trace-Util Perl module and some scripts that use it. ... new file mode 100644 ... +GNU General Public License version 2 as published by the Free ... +sub define_flag_field ...
    (Linux-Kernel)
  • RE: returning hashes, and arrays
    ... :> subroutine named link(). ... :> array interchangeably here. ... : 'Learning Perl'; ... : sub ParseLineForHomeAndVisitors; ...
    (perl.beginners)
  • Re: Shifting Away
    ... are there two armed camps of Perl monks throwing gazillion megawatt ... daily at shift change and shout "When should I use an en dash?" ... become a bit less paranoid now but it's hard to let go of formal params. ... in the argument list and the sub could still change that. ...
    (comp.lang.perl.misc)
  • [RFC][PATCH 4/7] perf trace: Add perf trace scripting support modules for Perl
    ... Add Perf-Trace-Util Perl module and some scripts that use it. ... new file mode 100644 ... +GNU General Public License version 2 as published by the Free ... +sub define_flag_field ...
    (Linux-Kernel)
  • Re: Hardware hackers rejoice!
    ... I've tried to warm up to Perl ... sub getvar { ... # Given 0, the fan is off. ... # Display to LCD ...
    (Ubuntu)