thread trouble

A

Alexandre Jaquet

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
 
A

Alexandre Jaquet

phaylon a écrit :
Alexandre Jaquet wrote:




There's your answer, I would say.

I 've open module Thread :

311 BEGIN {
312 if ($ithreads) {
313 if ($othreads) {
314 require Carp;
315 Carp::croak("This Perl has both ithreads and
5005threads (serious malconfiguration)");
316 }
317 XSLoader::load 'threads';
318 for my $m (qw(new join detach yield self tid equal list)) {
319 no strict 'refs';
320 *{"Thread::$m"} = \&{"threads::$m"};
321 }
322 require 'threads/shared.pm';
323 for my $m (qw(cond_signal cond_broadcast cond_wait)) {
324 no strict 'refs';
325 *{"Thread::$m"} = \&{"threads::shared::${m}_enabled"};
326 }
327 # trying to unimplement eval gives redefined warning
328 unimplement(qw(done flags));
329 } elsif ($othreads) {
330 XSLoader::load 'Thread';
331 } else {
332 require Carp;
333 Carp::croak("This Perl has neither ithreads nor
5005threads");
334 }
335 }

I've checked if Carp was installed but don't understand why :s
 
A

Alexandre Jaquet

Alexandre Jaquet a écrit :
phaylon a écrit :


I 've open module Thread :

311 BEGIN {
312 if ($ithreads) {
313 if ($othreads) {
314 require Carp;
315 Carp::croak("This Perl has both ithreads and
5005threads (serious malconfiguration)");
316 }
317 XSLoader::load 'threads';
318 for my $m (qw(new join detach yield self tid equal list)) {
319 no strict 'refs';
320 *{"Thread::$m"} = \&{"threads::$m"};
321 }
322 require 'threads/shared.pm';
323 for my $m (qw(cond_signal cond_broadcast cond_wait)) {
324 no strict 'refs';
325 *{"Thread::$m"} = \&{"threads::shared::${m}_enabled"};
326 }
327 # trying to unimplement eval gives redefined warning
328 unimplement(qw(done flags));
329 } elsif ($othreads) {
330 XSLoader::load 'Thread';
331 } else {
332 require Carp;
333 Carp::croak("This Perl has neither ithreads nor
5005threads");
334 }
335 }

I've checked if Carp was installed but don't understand why :s

I checked perl -V and got :

ummary of my perl5 (revision 5 version 8 subversion 6) configuration:
....
-Dusethreads=n - is that the problem ?
 
C

Chris Mattern

Alexandre said:
I checked perl -V and got :

ummary of my perl5 (revision 5 version 8 subversion 6) configuration:
...
-Dusethreads=n - is that the problem ?

Uh, yah. Perl has to be compiled to use threads or it can't. Your
perl isn't compiled to use threads. You're going to need to build
a new instance of perl with threads enabled if you want to use threads.

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,218
Latest member
JolieDenha

Latest Threads

Top