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
Svante Signell
September 23, 2014 13:21
Re: [perl #122657] t/io/socket.t failing on hurd: peer from recv()should be empty or the remote name
Message ID:
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 <
> > 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 but I would expect recv to return the
> > actual
> > IP address used in the socket, not  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
        elsif (defined $pid) {
            #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():


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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About