Update: it would seem the problem is actually located within this part:
and thus really has nothing to do with the actual select call...looks like I need to divert my attention to seeing what goes wrong in the sysreadline() call :/while(my $line = $buffer->sysreadline($fh)) { chomp($line); $self->_process($line); } }
Update 2 Well, what do you know, if sysreadline always appends a lineend to its return call, even when the actual line itself is empty, then it'll always evaluate to true, and the inner while loop above will never exit. Now if you'll all please excuse me, I need to find a really hard object to bang my head against for wasting your and my time in this way ;-)
this has been baffling me for a few days already so I thought I might turn to you all for help. I have the following little while/select loop in my code:
Note that $buffer in this case points towards a little thingamabob I wrote on top of IO::Select. Suffice to say that $buffer->ready performs an IO::Select->can_read with a timeout of 0.001. What's going wrong here is that the 2 print statements are executed once when the script is started and then never again. I know the while loop is being walked through time and time again, because everytime there is something available in @ready it is indeed processed in the second part of the loop. I've tried changing the 2 print statements to print explicitly to STDOUT but no such luck either. I even tried to blame my poor lil' WinXP box but then it turned out the FreeBSD server does the same. Any ideas on what this might be?sub run { while(1) { my @ready; print "about to check buffers\n"; unless(@ready = $buffer->ready) { select(undef, undef, undef, 0.001); next; } print "just after checking buffers\n"; foreach my $fh (@ready) { my $self = $objects{$fh}; while(my $line = $buffer->sysreadline($fh)) { chomp($line); $self->_process($line); } } } }
In reply to select loop madness by Forsaken
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |