develooper Front page | perl.perl5.porters | Postings from September 2014

Re: [perl #122657] t/io/socket.t failing on hurd: peer from recv()should be empty or the remote name

Thread Next
From:
Svante Signell
Date:
September 23, 2014 13:21
Subject:
Re: [perl #122657] t/io/socket.t failing on hurd: peer from recv()should be empty or the remote name
Message ID:
1411460757.28919.23.camel@G3620.my.own.domain
On Mon, 2014-09-22 at 17:32 -0700, Tony Cook via RT wrote:
> On Sat Aug 30 17:17:18 2014, dom wrote:
> > As reported in <https://bugs.debian.org/cgi-
> > bin/bugreport.cgi?bug=758718> this test (introduced as part of [perl
> > #118843]) fails on Hurd. The comment from the Hurd porting team is:
> > 
> > "The test seems fishy to me: it is making sure that the name as
> > returned
> > by recv is *exactly* the same as what the server socket is bound to,
> > which is 0.0.0.0:some_port but I would expect recv to return the
> > actual
> > IP address used in the socket, not 0.0.0.0.  It happens that Linux
> > doesn't return anything at all so it goes fine there, but that's not a
> > reason."
> 
> If it compared against getpeername(), would that pass?
> 
> As you say, comparing against the bind address is just plain wrong.
> 
> I don't have ready access to Hurd.

I think there is something wrong with this test, even comparing with
getpeername():
        elsif (defined $pid) {
            curr_test(curr_test()+2);
            #sleep 1;
            # child
            ok_child(close($serv), "close server socket in child");
            ok_child(socket(my $child, PF_INET, SOCK_STREAM, $tcp),
               "make child tcp socket");

            ok_child(connect($child, $bind_name), "connect() works")
                or diag "connect error: $!";

            my $buf;
            my $recv_peer = recv($child, $buf, 1000, 0);
            # [perl #118843]
            ok_child($recv_peer eq '' || $recv_peer eq $bind_name,
               "peer from recv() should be empty or the remote name");

The return value of recv() should be the number of bytes returned?? I've
tested on both Linux and Hurd and the received value in both cases is
zero. (and the return value of $bind_name is zero too!)

From the man page of recv():

RETURN VALUE

These calls return the number of bytes received, or -1 if an error
occurred.  In the event of an error, errno is set to indicate the error.

When a stream socket peer has performed an orderly shutdown, the return
value  will  be  0 (the traditional "end-of-file" return).

Datagram sockets in various  domains (e.g., the UNIX and Internet
domains) permit zero-length datagrams.  When such a datagram is
received, the return value is 0.

The value 0 may also be returned if the requested number of bytes to
receive from a stream socket was 0.




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About