With 5.8.1 I get

Child: connected and exitting
Child: connected and exitting
Spawning again
Attempt to free unreferenced scalar at /usr/home/timbo/dbi/trunk/blib/lib/DBI.pm line 
643.
Attempt to free unreferenced scalar at /usr/home/timbo/dbi/trunk/blib/lib/DBI.pm line 
643.
Attempt to free unreferenced scalar at /usr/home/timbo/dbi/trunk/blib/lib/DBI.pm line 
643.
Child: connected and exitting
Attempt to free unreferenced scalar at /usr/home/timbo/dbi/trunk/blib/lib/DBI.pm line 
643.
Attempt to free unreferenced scalar at /usr/home/timbo/dbi/trunk/blib/lib/DBI.pm line 
643.
Attempt to free unreferenced scalar at /usr/home/timbo/dbi/trunk/blib/lib/DBI.pm line 
643.
Child: connected and exitting
Test completed

and 5.8.3 I get

Child: connected and exitting
Child: connected and exitting
Spawning again
Child: connected and exitting
Child: connected and exitting
Test completed

So I presume it was a perl bug that's now fixed.

(I've fixed the warning about redefining the DBD::Sponge method)

Tim.

On Tue, Feb 17, 2004 at 11:17:47AM -0800, Dean Arnold wrote:
> I've managed to recreate the threading issue
> with DBD::Sponge (see script below) ( I also 
> modified DBD::Sponge - not included below -
> to add an $installed flag for its one
> installed method)
> 
> The secret seems to be spawning a few threads that
> connect(), then disconnect and exit, then
> spawning some more threads that connect().
> The 2nd set of threads generate the warning msg.
> 
> The interesting thing is that the scalar it complains about
> is the same in all cases.
> 
> I'll try this on 5.8.3 when I get a chance.
> 
> ###############################################################
> 
> #!/usr/local/bin/perl -w
> use DBI;
> use DBI qw(:sql_types);
> use Config;
> use threads;
> use threads::shared; # so we can share data
> use Thread::Queue; # a thread-safe shared  queue!
> #
> # verify threads are available
> #
> die 'Perl not built with threads'
>  unless $Config{useithreads};
> #
> # open a connection in main thread
> #
> my $maindbh = DBI->connect('dbi:Sponge:', '','', {
>  PrintError => 1,
>  RaiseError => 0,
>  AutoCommit => 1
> }) || die DBI->errstr;
> #
> # now spawn a thread that opens a connection
> #
> my $queue = Thread::Queue->new();
> push @thrds, threads->create(\&child_thread, $queue)
>  foreach (1..2);
> $queue->enqueue('go') foreach (1..2);
> #
> # wait for completion
> #
> $_->join foreach (@thrds);
> #
> # now spawn again
> #
> @thrds = ();
> print "Spawning again\n";
> push @thrds, threads->create(\&child_thread, $queue)
>  foreach (1..2);
> $queue->enqueue('go') foreach (1..2);
> #
> # wait for completion
> #
> $_->join foreach (@thrds);
> 
> $maindbh->disconnect;
> print "Test completed\n";
> 
> sub child_thread {
>  my ($queue) = @_;
>  
>  $queue->dequeue();
> my $dbh = DBI->connect('dbi:Sponge:', '', '', {
>  PrintError => 1,
>  RaiseError => 0,
>  AutoCommit => 1
> }) || die DBI->errstr;
> print "Child: connected and exitting\n";
> $dbh->disconnect;
> }
> __END__
> Dean Arnold
> Presicient Corp.
> www.presicient.com

Reply via email to