in reply to threads hang
I've managed to reproduce this on a single cpu windows machine with AS5.8.8 (using ping instead of smtp) and it appears to be a bug in the handling of backticks within threads.
The symptoms I am seeing are that one thread hangs, never returning from the backticks, even though I can see that all instances of the executable (ping.exe) have terminated. Using this simplified version of your thread code with added trace:
sub SNMPthread { my $thread = shift; while ( my $left = $q->pending ) { warn "$thread: $left"; my $ip = $q->dequeue; warn "$thread: $left, $ip"; my $return = `ping $ip`; warn sprintf "$thread: $left got %d bytes of output\n", length + $return; my @ele = split ' ', $return; warn "$thread: $left, $ip, $ele[ -4 ], $ele[ -1 ]"; } warn "thread $thread finished\n"; }
The trace for the hanging thread is:
8: 94 at C:\test\662828.pl line 30. 8: 94, 212.58.227.137 at C:\test\662828.pl line 32. 8: 94 got 471 bytes of output 8: 94, 212.58.227.137, 204ms,, 192ms at C:\test\662828.pl line 36. 8: 88 at C:\test\662828.pl line 30. 8: 88, 30.207.168.74 at C:\test\662828.pl line 32. 8: 88 got 228 bytes of output 8: 88, 30.207.168.74, =, loss), at C:\test\662828.pl line 36. 8: 78 at C:\test\662828.pl line 30. 8: 78, 202.229.106.211 at C:\test\662828.pl line 32.
As you can see, each IP is producing 4 lines of trace. Two before the backticks and two after. On it's third attempt, the backticks hang. However, the spawned ping instance goes away, so it's internal to Perl rather than the executable where the hang is occuring. The latter also suggested by the fact I can reproduce it using a different executable under a different OS.
I've tried substituting a piped open for backticks and varied the number of threads with the same result. Always one thread only that hangs. So it appears to be an internal problem that is the culprit.
However, I do have a fix for you. Upgrade to 5.10.0. The same code completes successfully using it, which also tends to indicate that it's a Perl problem, that's been fixed already.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: threads hang
by Ryszard (Priest) on Jan 17, 2008 at 15:55 UTC | |
by BrowserUk (Patriarch) on Jan 17, 2008 at 16:17 UTC |