[pypy-commit] pypy default: fixes for RSocket IPV6 support
bdkearns
noreply at buildbot.pypy.org
Fri Mar 22 00:29:04 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r62619:bd0e0b2b11bb
Date: 2013-03-21 19:28 -0400
http://bitbucket.org/pypy/pypy/changeset/bd0e0b2b11bb/
Log: fixes for RSocket IPV6 support
diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py
--- a/rpython/rlib/_rsocket_rffi.py
+++ b/rpython/rlib/_rsocket_rffi.py
@@ -262,7 +262,7 @@
CConfig.in_addr = platform.Struct('struct in_addr',
[('s_addr', rffi.UINT)])
CConfig.in6_addr = platform.Struct('struct in6_addr',
- [])
+ [('s6_addr', rffi.CFixedArray(rffi.CHAR, 16))])
CConfig.sockaddr_in = platform.Struct('struct sockaddr_in',
[('sin_family', rffi.INT),
('sin_port', rffi.USHORT),
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -339,7 +339,7 @@
# to avoid leaks if an exception occurs inbetween
sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True)
result.setdata(sin, sizeof(_c.sockaddr_in6))
- rffi.setintfield(sin, 'c_sin6_family', AF_INET)
+ rffi.setintfield(sin, 'c_sin6_family', AF_INET6)
rffi.structcopy(sin.c_sin6_addr, in6_addr)
return result
from_in6_addr = staticmethod(from_in6_addr)
diff --git a/rpython/rlib/test/test_rsocket.py b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -68,17 +68,17 @@
% (address_list,))
def test_gethostbyaddr():
- for host in ["localhost", "127.0.0.1"]:
+ for host in ["localhost", "127.0.0.1", "::1"]:
name, aliases, address_list = gethostbyaddr(host)
allnames = [name] + aliases
for n in allnames:
assert isinstance(n, str)
if sys.platform != 'win32':
- assert 'localhost' in allnames
+ assert 'localhost' in allnames or 'ip6-localhost' in allnames
for a in address_list:
if isinstance(a, INETAddress) and a.get_host() == "127.0.0.1":
break # ok
- if host == 'localhost': # name lookup might return IPV6
+ if host != '127.0.0.1': # name lookup might return IPV6
if isinstance(a, INET6Address) and a.get_host() == "::1":
break # ok
else:
More information about the pypy-commit
mailing list