Skip Menu |

This queue is for tickets about the Net-Daemon CPAN distribution.

Report information
The Basics
Id: 39759
Status: resolved
Priority: 0/
Queue: Net-Daemon

People
Owner: Nobody in particular
Requestors: plautrba [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.43
Fixed in: (no value)



Subject: make test fails on t/thread
t/thread........lock can only be used on shared values at t/server line 73, <GEN3> line 1. perl, v5.10.0 built for x86_64-linux-thread-multi there is new thread implementation ithread from perl 5.6.0 and since perl 5.10 was old threads removed. I suggest use only ithreads and remove locking by $Net::Daemon::RegExpLock as in attached patch
Subject: Net-Daemon-only-ithreads.patch
From 8b8ffe4a95dce799d72b13826900c382a19e7e9e Mon Sep 17 00:00:00 2001 From: Petr Lautrbach <bach@dhcp-lab-183.englab.brq.redhat.com> Date: Thu, 2 Oct 2008 12:08:17 +0200 Subject: [PATCH] remove Thread --- README | 12 +++--- lib/Net/Daemon.pm | 41 ++++-------------- t/server | 2 - t/thread.t | 59 -------------------------- t/threadm.t | 121 ----------------------------------------------------- 5 files changed, 14 insertions(+), 221 deletions(-) delete mode 100644 t/thread.t delete mode 100644 t/threadm.t diff --git a/README b/README index be4444e..c4b53a5 100644 --- a/README +++ b/README @@ -14,8 +14,8 @@ SYNOPSIS DESCRIPTION Net::Daemon is an abstract base class for implementing portable server - applications in a very simple way. The module is designed for Perl 5.005 - and threads, but can work with fork() and Perl 5.004. + applications in a very simple way. The module is designed for Perl 5.006 + and ithreads, but can work with fork() and Perl 5.004. The Net::Daemon class offers methods for the most common tasks a daemon needs: Starting up, logging, accepting clients, authorization, @@ -142,11 +142,10 @@ DESCRIPTION The Net::Daemon server can run in three different modes, depending on the environment. - If you are running Perl 5.005 and did compile it for threads, then + If you are running Perl 5.006 and did compile it for ithreads, then the server will create a new thread for each connection. The thread will execute the server's Run() method and then terminate. This mode - is the default, you can force it with "--mode=ithreads" or - "--mode=threads". + is the default, you can force it with "--mode=ithreads". If threads are not available, but you have a working fork(), then the server will behave similar by creating a new process for each @@ -156,7 +155,7 @@ DESCRIPTION Finally there's a single-connection mode: If the server has accepted a connection, he will enter the Run() method. No other connections are accepted until the Run() method returns. This operation mode is - useful if you have neither threads nor fork(), for example on the + useful if you have neither ithreads nor fork(), for example on the Macintosh. For debugging purposes you can force this mode with "--mode=single". @@ -368,6 +367,7 @@ EXAMPLE require Net::Daemon; + package Calculator; use vars qw($VERSION @ISA); diff --git a/lib/Net/Daemon.pm b/lib/Net/Daemon.pm index 4ebe5c7..9d97d4a 100644 --- a/lib/Net/Daemon.pm +++ b/lib/Net/Daemon.pm @@ -33,15 +33,9 @@ use POSIX (); package Net::Daemon; -$Net::Daemon::VERSION = '0.43'; +$Net::Daemon::VERSION = '0.44'; @Net::Daemon::ISA = qw(Net::Daemon::Log); -# -# Regexps aren't thread safe, as of 5.00502 :-( (See the test script -# regexp-threads.) -# -$Net::Daemon::RegExpLock = 1; - use vars qw($exit); ############################################################################ @@ -107,7 +101,7 @@ sub Options ($) { . 'Looping mode, <secs> seconds per loop' }, 'mode' => { 'template' => 'mode=s', 'description' => '--mode <mode> ' - . 'Operation mode (threads, fork or single)' }, + . 'Operation mode (ithreads, threads (same as ithreads), fork or single)' }, 'pidfile' => { 'template' => 'pidfile=s', 'description' => '--pidfile <file> ' . 'Use <file> as PID file' }, @@ -256,8 +250,6 @@ sub new ($$;$) { } elsif (!defined($self->{'mode'})) { if (eval { require thread }) { $self->{'mode'} = 'ithreads'; - } elsif (eval { require Thread }) { - $self->{'mode'} = 'threads'; } else { my $fork = 0; if ($^O ne "MSWin32") { @@ -276,10 +268,9 @@ sub new ($$;$) { } } + $self->{'mode'} = 'ithreads' if ($self->{'mode'} eq 'threads'); if ($self->{'mode'} eq 'ithreads') { require threads; - } elsif ($self->{'mode'} eq 'threads') { - require Thread; } elsif ($self->{'mode'} eq 'fork') { # Initialize forking mode ... } elsif ($self->{'mode'} eq 'single') { @@ -354,13 +345,6 @@ sub Accept ($) { my $masks = ref($client->{'mask'}) ? $client->{'mask'} : [ $client->{'mask'} ]; - # - # Regular expressions aren't thread safe, as of - # 5.00502 :-( - # - my $lock; - $lock = lock($Net::Daemon::RegExpLock) - if ($self->{'mode'} eq 'threads'); foreach my $mask (@$masks) { foreach my $alias (@patterns) { if ($alias =~ /$mask/) { @@ -459,14 +443,6 @@ sub ChildFunc { my($self, $method, @args) = @_; if ($self->{'mode'} eq 'single') { $self->$method(@args); - } elsif ($self->{'mode'} eq 'threads') { - my $startfunc = sub { - my $self = shift; - my $method = shift; - $self->$method(@_) - }; - Thread->new($startfunc, $self, $method, @args) - or die "Failed to create a new thread: $!"; } elsif ($self->{'mode'} eq 'ithreads') { my $startfunc = sub { my $self = shift; @@ -730,8 +706,8 @@ Net::Daemon - Perl extension for portable daemons =head1 DESCRIPTION Net::Daemon is an abstract base class for implementing portable server -applications in a very simple way. The module is designed for Perl 5.005 -and threads, but can work with fork() and Perl 5.004. +applications in a very simple way. The module is designed for Perl 5.006 +and ithreads, but can work with fork() and Perl 5.004. The Net::Daemon class offers methods for the most common tasks a daemon needs: Starting up, logging, accepting clients, authorization, restricting @@ -875,11 +851,10 @@ I<loop-timeout>. The Net::Daemon server can run in three different modes, depending on the environment. -If you are running Perl 5.005 and did compile it for threads, then +If you are running Perl 5.006 and did compile it for ithreads, then the server will create a new thread for each connection. The thread will execute the server's Run() method and then terminate. This mode -is the default, you can force it with "--mode=ithreads" or -"--mode=threads". +is the default, you can force it with "--mode=ithreads". If threads are not available, but you have a working fork(), then the server will behave similar by creating a new process for each connection. @@ -889,7 +864,7 @@ you use the "--mode=fork" option. Finally there's a single-connection mode: If the server has accepted a connection, he will enter the Run() method. No other connections are accepted until the Run() method returns. This operation mode is useful -if you have neither threads nor fork(), for example on the Macintosh. +if you have neither ithreads nor fork(), for example on the Macintosh. For debugging purposes you can force this mode with "--mode=single". When running in mode single, you can still handle multiple clients at diff --git a/t/server b/t/server index 0bb2a23..3537495 100644 --- a/t/server +++ b/t/server @@ -70,8 +70,6 @@ sub Run ($) { } my $num; { - my $lock = lock($Net::Daemon::RegExpLock) - if ($self->{'mode'} eq 'threads'); if ($line =~ /(\d+)/) { $num = $1; } diff --git a/t/thread.t b/t/thread.t deleted file mode 100644 index 5567503..0000000 --- a/t/thread.t +++ /dev/null @@ -1,59 +0,0 @@ -# -*- perl -*- -# -# $Id: thread.t,v 1.2 1999/08/12 14:28:59 joe Exp $ -# - -require 5.004; -use strict; - -use IO::Socket (); -use Config (); -use Net::Daemon::Test (); - -my $numTests = 5; - - -# Check whether threads are available, otherwise skip this test. - -if (!eval { require Thread; my $t = Thread->new(sub { }) }) { - print "1..0\n"; - exit 0; -} - -my($handle, $port) = Net::Daemon::Test->Child - ($numTests, $^X, 't/server', '--timeout', 20, '--mode=threads'); - - -print "Making first connection to port $port...\n"; -my $fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', - 'PeerPort' => $port); -printf("%s 1\n", $fh ? "ok" : "not ok"); -printf("%s 2\n", $fh->close() ? "ok" : "not ok"); -print "Making second connection to port $port...\n"; -$fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', - 'PeerPort' => $port); -printf("%s 3\n", $fh ? "ok" : "not ok"); -eval { - for (my $i = 0; $i < 20; $i++) { - if (!$fh->print("$i\n") || !$fh->flush()) { - die "Error while writing $i: " . $fh->error() . " ($!)"; - } - my $line = $fh->getline(); - die "Error while reading $i: " . $fh->error() . " ($!)" - unless defined($line); - die "Result error: Expected " . ($i*2) . ", got $line" - unless ($line =~ /(\d+)/ && $1 == $i*2); - } -}; -if ($@) { - print STDERR "$@\n"; - print "not ok 4\n"; -} else { - print "ok 4\n"; -} -printf("%s 5\n", $fh->close() ? "ok" : "not ok"); - -END { - if ($handle) { $handle->Terminate() } - if (-f "ndtest.prt") { unlink "ndtest.prt" } -} diff --git a/t/threadm.t b/t/threadm.t deleted file mode 100644 index 518ccf6..0000000 --- a/t/threadm.t +++ /dev/null @@ -1,121 +0,0 @@ -# -*- perl -*- -# -# $Id: threadm.t,v 1.3 2007/05/16 13:58 mhn $ -# - -require 5.004; -use strict; - -use IO::Socket (); -use Config (); -use Net::Daemon::Test (); -use Fcntl (); -use Config (); - - -$| = 1; -$^W = 1; - - -if (!$Config::Config{'usethreads'} || - $Config::Config{'usethreads'} ne 'define' || - !eval { require Thread }) { - print "1..0\n"; - exit 0; -} - - -my($handle, $port); -if (@ARGV) { - $port = shift @ARGV; -} else { - ($handle, $port) = Net::Daemon::Test->Child - (10, $^X, '-Iblib/lib', '-Iblib/arch', 't/server', - '--mode=threads', 'logfile=stderr', 'debug'); -} - - -my $regexpLock = 1; -sub IsNum { - # - # Regular expressions aren't thread safe, as of 5.00502 :-( - # - my $lock = lock($regexpLock); - my $str = shift; - (defined($str) && $str =~ /(\d+)/) ? $1 : undef; -} - - -sub ReadWrite { - my $fh = shift; my $i = shift; my $j = shift; - die "Child $i: Error while writing $j: $!" - unless $fh->print("$j\n") and $fh->flush(); - my $line = $fh->getline(); - die "Child $i: Error while reading: " . $fh->error() . " ($!)" - unless defined($line); - my $num = IsNum($line); - die "Child $i: Cannot parse result: $line" - unless defined($num); - die "Child $i: Expected " . ($j*2) . ", got $num" - unless ($num == $j*2); -} - - -sub MyChild { - my $i = shift; - - eval { - my $fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', - 'PeerPort' => $port); - die "Cannot connect: $!" unless defined($fh); - for (my $j = 0; $j < 1000; $j++) { - ReadWrite($fh, $i, $j); - } - }; - if ($@) { - print STDERR $@; - return 0; - } - return 1; -} - -my @threads = (); - -if (!$Config::Config{'usethreads'} || - $Config::Config{'usethreads'} ne 'define') { - - for (my $i = 0; $i < 10; $i++) { - #print "Spawning child $i.\n"; - my $tid = Thread->new(\&MyChild, $i); - if (!$tid) { - print STDERR "Failed to create new thread: $!\n"; - exit 1; - } - push(@threads, $tid); - } - -} -eval { alarm 1; alarm 0 }; -alarm 120 unless $@; -for (my $i = 1; $i <= 10; $i++) { - if (@threads) { - my $tid = shift @threads; - if ($tid->join()) { - print "ok $i\n"; - } else { - print "not ok $i\n"; - } - } else { - print "ok $i\n"; # Fake output for Windows when - # Perl -V reveals usethreads - } -} - -END { - if ($handle) { - print "Terminating server.\n"; - $handle->Terminate(); - undef $handle; - } - unlink "ndtest.prt"; -} -- 1.5.5.1
From: plautrba [...] redhat.com
On Thu Oct 02 06:21:49 2008, bach wrote: Show quoted text
> I suggest use only ithreads and remove locking by > $Net::Daemon::RegExpLock as in attached patch > >
I forgot modify MANIFEST. Here is updated patch Petr
diff --git a/README b/README index be4444e..c4b53a5 100644 --- a/README +++ b/README @@ -14,8 +14,8 @@ SYNOPSIS DESCRIPTION Net::Daemon is an abstract base class for implementing portable server - applications in a very simple way. The module is designed for Perl 5.005 - and threads, but can work with fork() and Perl 5.004. + applications in a very simple way. The module is designed for Perl 5.006 + and ithreads, but can work with fork() and Perl 5.004. The Net::Daemon class offers methods for the most common tasks a daemon needs: Starting up, logging, accepting clients, authorization, @@ -142,11 +142,10 @@ DESCRIPTION The Net::Daemon server can run in three different modes, depending on the environment. - If you are running Perl 5.005 and did compile it for threads, then + If you are running Perl 5.006 and did compile it for ithreads, then the server will create a new thread for each connection. The thread will execute the server's Run() method and then terminate. This mode - is the default, you can force it with "--mode=ithreads" or - "--mode=threads". + is the default, you can force it with "--mode=ithreads". If threads are not available, but you have a working fork(), then the server will behave similar by creating a new process for each @@ -156,7 +155,7 @@ DESCRIPTION Finally there's a single-connection mode: If the server has accepted a connection, he will enter the Run() method. No other connections are accepted until the Run() method returns. This operation mode is - useful if you have neither threads nor fork(), for example on the + useful if you have neither ithreads nor fork(), for example on the Macintosh. For debugging purposes you can force this mode with "--mode=single". @@ -368,6 +367,7 @@ EXAMPLE require Net::Daemon; + package Calculator; use vars qw($VERSION @ISA); diff --git a/lib/Net/Daemon.pm b/lib/Net/Daemon.pm index 4ebe5c7..9d97d4a 100644 --- a/lib/Net/Daemon.pm +++ b/lib/Net/Daemon.pm @@ -33,15 +33,9 @@ use POSIX (); package Net::Daemon; -$Net::Daemon::VERSION = '0.43'; +$Net::Daemon::VERSION = '0.44'; @Net::Daemon::ISA = qw(Net::Daemon::Log); -# -# Regexps aren't thread safe, as of 5.00502 :-( (See the test script -# regexp-threads.) -# -$Net::Daemon::RegExpLock = 1; - use vars qw($exit); ############################################################################ @@ -107,7 +101,7 @@ sub Options ($) { . 'Looping mode, <secs> seconds per loop' }, 'mode' => { 'template' => 'mode=s', 'description' => '--mode <mode> ' - . 'Operation mode (threads, fork or single)' }, + . 'Operation mode (ithreads, threads (same as ithreads), fork or single)' }, 'pidfile' => { 'template' => 'pidfile=s', 'description' => '--pidfile <file> ' . 'Use <file> as PID file' }, @@ -256,8 +250,6 @@ sub new ($$;$) { } elsif (!defined($self->{'mode'})) { if (eval { require thread }) { $self->{'mode'} = 'ithreads'; - } elsif (eval { require Thread }) { - $self->{'mode'} = 'threads'; } else { my $fork = 0; if ($^O ne "MSWin32") { @@ -276,10 +268,9 @@ sub new ($$;$) { } } + $self->{'mode'} = 'ithreads' if ($self->{'mode'} eq 'threads'); if ($self->{'mode'} eq 'ithreads') { require threads; - } elsif ($self->{'mode'} eq 'threads') { - require Thread; } elsif ($self->{'mode'} eq 'fork') { # Initialize forking mode ... } elsif ($self->{'mode'} eq 'single') { @@ -354,13 +345,6 @@ sub Accept ($) { my $masks = ref($client->{'mask'}) ? $client->{'mask'} : [ $client->{'mask'} ]; - # - # Regular expressions aren't thread safe, as of - # 5.00502 :-( - # - my $lock; - $lock = lock($Net::Daemon::RegExpLock) - if ($self->{'mode'} eq 'threads'); foreach my $mask (@$masks) { foreach my $alias (@patterns) { if ($alias =~ /$mask/) { @@ -459,14 +443,6 @@ sub ChildFunc { my($self, $method, @args) = @_; if ($self->{'mode'} eq 'single') { $self->$method(@args); - } elsif ($self->{'mode'} eq 'threads') { - my $startfunc = sub { - my $self = shift; - my $method = shift; - $self->$method(@_) - }; - Thread->new($startfunc, $self, $method, @args) - or die "Failed to create a new thread: $!"; } elsif ($self->{'mode'} eq 'ithreads') { my $startfunc = sub { my $self = shift; @@ -730,8 +706,8 @@ Net::Daemon - Perl extension for portable daemons =head1 DESCRIPTION Net::Daemon is an abstract base class for implementing portable server -applications in a very simple way. The module is designed for Perl 5.005 -and threads, but can work with fork() and Perl 5.004. +applications in a very simple way. The module is designed for Perl 5.006 +and ithreads, but can work with fork() and Perl 5.004. The Net::Daemon class offers methods for the most common tasks a daemon needs: Starting up, logging, accepting clients, authorization, restricting @@ -875,11 +851,10 @@ I<loop-timeout>. The Net::Daemon server can run in three different modes, depending on the environment. -If you are running Perl 5.005 and did compile it for threads, then +If you are running Perl 5.006 and did compile it for ithreads, then the server will create a new thread for each connection. The thread will execute the server's Run() method and then terminate. This mode -is the default, you can force it with "--mode=ithreads" or -"--mode=threads". +is the default, you can force it with "--mode=ithreads". If threads are not available, but you have a working fork(), then the server will behave similar by creating a new process for each connection. @@ -889,7 +864,7 @@ you use the "--mode=fork" option. Finally there's a single-connection mode: If the server has accepted a connection, he will enter the Run() method. No other connections are accepted until the Run() method returns. This operation mode is useful -if you have neither threads nor fork(), for example on the Macintosh. +if you have neither ithreads nor fork(), for example on the Macintosh. For debugging purposes you can force this mode with "--mode=single". When running in mode single, you can still handle multiple clients at diff --git a/t/server b/t/server index 0bb2a23..3537495 100644 --- a/t/server +++ b/t/server @@ -70,8 +70,6 @@ sub Run ($) { } my $num; { - my $lock = lock($Net::Daemon::RegExpLock) - if ($self->{'mode'} eq 'threads'); if ($line =~ /(\d+)/) { $num = $1; } diff --git a/t/thread.t b/t/thread.t deleted file mode 100644 index 5567503..0000000 --- a/t/thread.t +++ /dev/null @@ -1,59 +0,0 @@ -# -*- perl -*- -# -# $Id: thread.t,v 1.2 1999/08/12 14:28:59 joe Exp $ -# - -require 5.004; -use strict; - -use IO::Socket (); -use Config (); -use Net::Daemon::Test (); - -my $numTests = 5; - - -# Check whether threads are available, otherwise skip this test. - -if (!eval { require Thread; my $t = Thread->new(sub { }) }) { - print "1..0\n"; - exit 0; -} - -my($handle, $port) = Net::Daemon::Test->Child - ($numTests, $^X, 't/server', '--timeout', 20, '--mode=threads'); - - -print "Making first connection to port $port...\n"; -my $fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', - 'PeerPort' => $port); -printf("%s 1\n", $fh ? "ok" : "not ok"); -printf("%s 2\n", $fh->close() ? "ok" : "not ok"); -print "Making second connection to port $port...\n"; -$fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', - 'PeerPort' => $port); -printf("%s 3\n", $fh ? "ok" : "not ok"); -eval { - for (my $i = 0; $i < 20; $i++) { - if (!$fh->print("$i\n") || !$fh->flush()) { - die "Error while writing $i: " . $fh->error() . " ($!)"; - } - my $line = $fh->getline(); - die "Error while reading $i: " . $fh->error() . " ($!)" - unless defined($line); - die "Result error: Expected " . ($i*2) . ", got $line" - unless ($line =~ /(\d+)/ && $1 == $i*2); - } -}; -if ($@) { - print STDERR "$@\n"; - print "not ok 4\n"; -} else { - print "ok 4\n"; -} -printf("%s 5\n", $fh->close() ? "ok" : "not ok"); - -END { - if ($handle) { $handle->Terminate() } - if (-f "ndtest.prt") { unlink "ndtest.prt" } -} diff --git a/t/threadm.t b/t/threadm.t deleted file mode 100644 index 518ccf6..0000000 --- a/t/threadm.t +++ /dev/null @@ -1,121 +0,0 @@ -# -*- perl -*- -# -# $Id: threadm.t,v 1.3 2007/05/16 13:58 mhn $ -# - -require 5.004; -use strict; - -use IO::Socket (); -use Config (); -use Net::Daemon::Test (); -use Fcntl (); -use Config (); - - -$| = 1; -$^W = 1; - - -if (!$Config::Config{'usethreads'} || - $Config::Config{'usethreads'} ne 'define' || - !eval { require Thread }) { - print "1..0\n"; - exit 0; -} - - -my($handle, $port); -if (@ARGV) { - $port = shift @ARGV; -} else { - ($handle, $port) = Net::Daemon::Test->Child - (10, $^X, '-Iblib/lib', '-Iblib/arch', 't/server', - '--mode=threads', 'logfile=stderr', 'debug'); -} - - -my $regexpLock = 1; -sub IsNum { - # - # Regular expressions aren't thread safe, as of 5.00502 :-( - # - my $lock = lock($regexpLock); - my $str = shift; - (defined($str) && $str =~ /(\d+)/) ? $1 : undef; -} - - -sub ReadWrite { - my $fh = shift; my $i = shift; my $j = shift; - die "Child $i: Error while writing $j: $!" - unless $fh->print("$j\n") and $fh->flush(); - my $line = $fh->getline(); - die "Child $i: Error while reading: " . $fh->error() . " ($!)" - unless defined($line); - my $num = IsNum($line); - die "Child $i: Cannot parse result: $line" - unless defined($num); - die "Child $i: Expected " . ($j*2) . ", got $num" - unless ($num == $j*2); -} - - -sub MyChild { - my $i = shift; - - eval { - my $fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', - 'PeerPort' => $port); - die "Cannot connect: $!" unless defined($fh); - for (my $j = 0; $j < 1000; $j++) { - ReadWrite($fh, $i, $j); - } - }; - if ($@) { - print STDERR $@; - return 0; - } - return 1; -} - -my @threads = (); - -if (!$Config::Config{'usethreads'} || - $Config::Config{'usethreads'} ne 'define') { - - for (my $i = 0; $i < 10; $i++) { - #print "Spawning child $i.\n"; - my $tid = Thread->new(\&MyChild, $i); - if (!$tid) { - print STDERR "Failed to create new thread: $!\n"; - exit 1; - } - push(@threads, $tid); - } - -} -eval { alarm 1; alarm 0 }; -alarm 120 unless $@; -for (my $i = 1; $i <= 10; $i++) { - if (@threads) { - my $tid = shift @threads; - if ($tid->join()) { - print "ok $i\n"; - } else { - print "not ok $i\n"; - } - } else { - print "ok $i\n"; # Fake output for Windows when - # Perl -V reveals usethreads - } -} - -END { - if ($handle) { - print "Terminating server.\n"; - $handle->Terminate(); - undef $handle; - } - unlink "ndtest.prt"; -} diff --git a/MANIFEST b/MANIFEST index e306721..442e86b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -17,7 +17,5 @@ t/loop.t Test the loop-timeout option t/loop-child.t Same with loop-child set t/server Script used by the server tests t/single.t Test of a single-mode server -t/thread.t Test of a multithreaded server -t/threadm.t Test of a multithreaded server with multiple clients t/unix.t Test for Unix sockets META.yml Module meta-data (added by MakeMaker)
On Thu Oct 02 06:54:13 2008, bach wrote: Show quoted text
> On Thu Oct 02 06:21:49 2008, bach wrote:
> > I suggest use only ithreads and remove locking by > > $Net::Daemon::RegExpLock as in attached patch > > > >
> > I forgot modify MANIFEST. Here is updated patch > > Petr >
Thanks - your post was useful. I agree that 5005threads support in the module must be removed in its entirety. However, to allow legacy code to co-exist meanwhile, I have attached a patch to Daemon.pm which fixes the make test issue with t/thread.t Rajesh
--- lib/Net/Daemon.pm Mon Jun 18 00:09:46 2007 +++ lib/Net/Daemon-patch.pm Thu Feb 5 10:51:16 2009 @@ -258,6 +258,11 @@ $self->{'mode'} = 'ithreads'; } elsif (eval { require Thread }) { $self->{'mode'} = 'threads'; + # this really is to allow legacy code to co-exist + if (eval { require threads::shared; }) { + if (defined(threads::shared->can("share"))) { + threads::shared::share(\$Net::Daemon::RegExpLock); + } + } } else { my $fork = 0; if ($^O ne "MSWin32") { @@ -280,6 +285,11 @@ require threads; } elsif ($self->{'mode'} eq 'threads') { require Thread; + if (eval { require threads::shared; }) { + if (defined(threads::shared->can("share"))) { + threads::shared::share(\$Net::Daemon::RegExpLock); + } + } } elsif ($self->{'mode'} eq 'fork') { # Initialize forking mode ... } elsif ($self->{'mode'} eq 'single') {
RT-Send-CC: mandaler [...] deshaw.com
Try Net-Daemon-0.46 I tried Net-Daemon-0.46 on Windows, Fedora Linux from a few months ago, then updated the Fedora and it still passes, so it looks like version 0.46 is a winner. Thank you very much for taking the time to report the bug.