Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: 2 problems using sockets perl 5.8 and mod_perl2 on Linux

by rr (Sexton)
on Jul 01, 2003 at 14:02 UTC ( #270472=note: print w/replies, xml ) Need Help??


in reply to Re: 2 problems using sockets perl 5.8 and mod_perl2 on Linux
in thread 2 problems using sockets perl 5.8 and mod_perl2 on Linux


Hello,

Okay, I grok this and removed the
if ($!) { print STDERR "ERROR $!\n"; }
I don't understand why even without checking this the loop spins uncontrolably until it times out (notice the use of Time::HiRes).

What I am observing as that this select loop keeps returning, $nf is set to 1, but there is no file descriptor in $eout, nor in $rout set to 1 and the loop just starts over again. This chomps up CPU and degrades the performance so badly I can't use it for it's intended purpose.

Is the logic I am using to detect readable or erroring file descriptors perhaps incorrect?

Thanks -- rr

Replies are listed 'Best First'.
Re: Re: Re: 2 problems using sockets perl 5.8 and mod_perl2 on Linux
by Thelonius (Priest) on Jul 03, 2003 at 03:05 UTC
    After much pondering, I think the problem is that you are initializing your bit vectors like this:
    my $rin = 0;
    but you should be doing this
    my $rin = '';
    When you say: $rin = 0; vec($rin, $fd, 1) = 1;, apparently the 0 is converted to the string "0" before the bit for $fd is set. This means that an extra bit will be set in each of your vectors.

    Personally, I've never understood vec() well enough to want to use it. I always use IO::Select and can_read() rather than that. I highly recommend the IO::Socket and IO::Select methods because they are so easy to use and, I think, less error-prone.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://270472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-07-04 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?