Bug#659075: [rt.cpan.org #61577] ->sockdomain and ->socktype undefined on newly ->accept'ed sockets

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Feb 16 05:18:03 UTC 2012


leonerd-cpan at leonerd.org.uk wrote:

> I'm not too happy about this patch currently, because it just
> "guesses" that sockopt 38 is SO_DOMAIN. I'm aware that Socket doesn't
> currently wrap SO_DOMAIN, and I'm happy to add that. The trouble is
> that there's a small chance some other OS has a different sockopt at
> 38, and this could lead to the wrong answer.

i'm pretty sure you mean 39 here, and not 38. :)  I grabbed that value
From the Linux headers on my debian system, and upon a wider review,
you're absolutely right that this was inappropriate:

 http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/sys/socket.h#SO_DOMAIN

I'm attaching a revised, simplified patch that doesn't make this
non-portable assumption.  On a Debian GNU/Linux wheezy (testing) system
right now, it still passes all tests.

> Until then, though I'd suggest just sticking to sockaddr_family() of
> getsockname() - that ought to be reliable enough I should think. 

https://mail.gnome.org/archives/commits-list/2011-September/msg00944.html
suggests that on Solaris, if the socket isn't connected, getsockname()
(i.e. Socket::->sockname()) will return an addrlen of 0 and not set the
sockaddr.

So in that situation, we'll at least be no worse off than the current
implementation, which seems reasonable.

Debian folks -- is this now a patch that folks feel comfortable
applying in anticipation of such a fix upstream?

        --dkg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: robustly-refresh-missing-cached-socket-details-v3.patch
Type: text/x-diff
Size: 864 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/perl-maintainers/attachments/20120216/9462c05a/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 965 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/perl-maintainers/attachments/20120216/9462c05a/attachment.pgp>


More information about the Perl-maintainers mailing list