2
0
mirror of https://opendev.org/x/pyghmi synced 2025-08-22 19:10:19 +00:00

Only bind on tmpsocket once

Since change I8f566543c8da28eb7ed76f1cb80ff4cb2dcbba96 openstackbmc has
failed to start with the error:

  socket.error: [Errno 22] Invalid argument

Moving the early bind so that it is only done when there is no server
specified has fixed the regression for openstackbmc.

Change-Id: Icb16cdc386fb08b54f28b7dff235eb697f1450ee
This commit is contained in:
Steve Baker
2015-11-02 16:05:03 +13:00
parent 1b5ae5d8e0
commit df19985878

View File

@@ -302,10 +302,10 @@ class Session(object):
tmpsocket = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) # INET6
# can do IPv4 if you are nice to it
tmpsocket.setsockopt(IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
# Rather than wait until send() to bind, bind now so that we have
# a port number allocated no matter what
tmpsocket.bind(('', 0))
if server is None:
# Rather than wait until send() to bind, bind now so that we have
# a port number allocated no matter what
tmpsocket.bind(('', 0))
cls.socketpool[tmpsocket] = 1
else:
tmpsocket.bind(server)