develooper Front page | perl.perl5.porters | Postings from December 1999

Re: IO::Select issue?

Thread Previous | Thread Next
Gurusamy Sarathy
December 2, 1999 22:23
Re: IO::Select issue?
Message ID:
On Wed, 27 Oct 1999 10:17:09 EDT, Marc Pavese wrote:
>I posted the below message to comp.lang.perl.misc a day or two ago,
>and got no responses. Since the "fix" I found to my problem involved
>editing one line of IO::Socket, I'm forwarding this to you to ask if
>you have any advice. I'm not at all sure that my fix was right. If so,
>great. If not, I'm hoping you can set me straight.
>Thanks very much,
>--text follows this line--
>I am writing some perl client/server code that uses IO::Select
>(version 1.13), and I am having a problem with the IO::Select::exists
>At one point in my code, I call $select->exists on a client socket
>to determine whether or not it has been terminated. I usually get the
>following warning when I call it on a client which is in fact gone:
>Use of uninitialized value at
>/usr/lib/perl5/5.00503/ppc-linux/IO/ line 49.
>The following change to line 49 of IO::Select makes the error
>--- /usr/lib/perl5/5.00503/ppc-linux/IO/     Thu Jul 23 23:45:41 1998
>+++   Tue Oct 19 18:39:59 1999
>@@ -46,7 +46,7 @@
> sub exists
> {
>  my $vec = shift;
>- $vec->[$vec->_fileno(shift) + FIRST_FD];
>+ $vec->[ ($vec->_fileno(shift) || 0) + FIRST_FD];
> }                               
>What is happening is that $vec->_filenoo is returning undef on the
>passed in socket. When you try to add undef with FIRST_FD, you get the
>Could someone tell me if this change makes sense at all?  I checked,
>and in the only other place in IO::Socket where _fileno is used (in
>the _update subroutine), the case of undef is specifically tested for
>so I guess undef is not an unexpected return value from _fileno.

Try this.

Change 4628 by gsar@auger on 1999/12/03 06:15:54

	avoid warning in IO::Select::exists() if socket doesn't exist

Affected files ...

... //depot/perl/ext/IO/lib/IO/ edit

Differences ...

==== //depot/perl/ext/IO/lib/IO/ (text) ====
Index: perl/ext/IO/lib/IO/
--- perl/ext/IO/lib/IO/	Thu Dec  2 22:17:34 1999
+++ perl/ext/IO/lib/IO/	Thu Dec  2 22:17:34 1999
@@ -46,7 +46,9 @@
 sub exists
  my $vec = shift;
- $vec->[$vec->_fileno(shift) + FIRST_FD];
+ my $fno = $vec->_fileno(shift);
+ return undef unless defined $fno;
+ $vec->[$fno + FIRST_FD];
End of Patch.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About