in reply to Re^2: win32 threads problem
in thread win32 threads problem
I've succeeded in reproducing your error, and the problem turns out to be associated with opendir/readdir/closedir. Regardless of whether the you use globals or lexicals; or whether the directory handle is closed prior to spawning the threads, you get a trap when trying to join the threads. That doesn't make much sense to me, but there we are.
I have a work around. Replace:
opendir (CDIR, $cfgFilesDir) or die; my $file; my $thr; while ($file = readdir(CDIR)) { if ($file =~ /.+?\.properties/) { $thr = threads->create(\&sendRequest, $file, 'localhost', $pee +rPort ); } } closedir (CDIR);
with
while( my $file = <*.properties> ) { ## Check the glob matches your fi +les! my $thr = threads->create(\&sendRequest, $file, 'localhost', $peer +Port ); }
And the global destruction problem will probably go away. At least it does here.
There are other problems in your code that you'll discover if you enable strict.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: win32 threads problem
by leonidlm (Pilgrim) on Dec 08, 2008 at 07:42 UTC | |
by BrowserUk (Patriarch) on Dec 08, 2008 at 08:10 UTC |