petesmiley has asked for the wisdom of the Perl Monks concerning the following question:
I provided a short code sample that produces the problem on my machine. I don't think it even makes it to the untie. To get rid of the segfault all I have to do is comment out the tie.
Maybe someone could point out something I'm doing wrong, or suggest a module that works better for this. Any advice would be appreciated.
smiles
#!/usr/bin/perl use strict; use threads; use threads::shared; use Thread::Queue; use SDBM_File; use Fcntl; # initialize some stuff my $q = Thread::Queue->new(); my %items : shared; tie %items,'SDBM_File','itemdb',O_CREAT|O_RDWR,0640 or die "Could not +open SDBM file: $!\n"; $items{$_} = 1 for 1..10; # play with 3 threads for (1..3) { threads->new(\&ttest) } my @threadlist = threads->list; $q->enqueue($_) for 1..10; $q->enqueue(undef) for @threadlist; $_->join for @threadlist; # clean up mess untie %items; unlink 'itemdb.pag','itemdb.dir'; sub ttest { while (my $qthingie = $q->dequeue) { print "$items{$qthingie}\n" } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: threads, tie and segmentation fault
by pg (Canon) on Feb 04, 2003 at 20:49 UTC | |
by petesmiley (Friar) on Feb 04, 2003 at 21:10 UTC | |
|
Re: threads, tie and segmentation fault
by petesmiley (Friar) on Feb 05, 2003 at 17:40 UTC | |
|
Re: threads, tie and segmentation fault
by perrin (Chancellor) on Feb 04, 2003 at 17:51 UTC | |
by petesmiley (Friar) on Feb 04, 2003 at 20:42 UTC |