Change in vdsm[master]: XMLRPCServer: make XMLRPCServer able to listen on IPv6 addre...

zhshzhou at linux.vnet.ibm.com zhshzhou at linux.vnet.ibm.com
Wed Mar 20 02:04:06 UTC 2013


Zhou Zheng Sheng has posted comments on this change.

Change subject: XMLRPCServer: make XMLRPCServer able to listen on IPv6 addresses
......................................................................


Patch Set 3: I would prefer that you didn't submit this

(1 inline comment)

....................................................
File vdsm/utils.py
Line 116: 
Line 117: class IPXMLRPCServer(SimpleXMLRPCServer):
Line 118:     def __init__(self, addr, requestHandler=IPXMLRPCRequestHandler,
Line 119:                  logRequests=True, allow_none=False, encoding=None,
Line 120:                  bind_and_activate=True):
Agree with Dan.

I also think the address family should be determined by getaddrinfo automatically from the string representation format of the address. In this way the code is independent from the IP version, like follow.

 self.address_family = socket.getaddrinfo(addr[0], addr[1])[0][0]

Here you avoid assigning AF_INET or AF_INET6 explicitly.

You can have a try in python console.

 
>>> import socket
>>> socket.getaddrinfo('::1', 0)
[(10, 1, 6, '', ('::1', 0, 0, 0)), (10, 2, 17, '', ('::1', 0, 0, 0)), (10, 3, 0, '', ('::1', 0, 0, 0))]
>>> socket.getaddrinfo('::1', 0)[0][0]
10
>>> socket.getaddrinfo('::1', 8080)[0][0]
10
>>> socket.getaddrinfo('::', 8080)[0][0]
10
>>> socket.getaddrinfo('127.0.0.1', 8080)[0][0]
2
>>> socket.getaddrinfo('0', 8080)[0][0]
2
>>> socket.AF_INET6
10
>>> socket.AF_INET
2

If addr contains a domain name or host name, getaddrinfo will resolve it to IP address, which makes the call slower. You can disable this behavior by setting AI_NUMERICHOST to the flags argument [1].

[1] http://docs.python.org/2/library/socket.html#socket.getaddrinfo
Line 121:         SimpleXMLRPCServer.__init__(self, addr, requestHandler,
Line 122:                                     logRequests, allow_none, encoding,
Line 123:                                     bind_and_activate=False)
Line 124:         if isIPv6Address(addr[0]):


--
To view, visit http://gerrit.ovirt.org/11520
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I50ab0ba59ac696da2d992afe453c6d3ceb111e94
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Hunt Xu <mhuntxu at gmail.com>
Gerrit-Reviewer: Assaf Muller <amuller at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Hunt Xu <mhuntxu at gmail.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list