Skip to content

Commit

Permalink
Use SO_REUSEADDR before calling bind() where missing. Fixes #1289.
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Apr 16, 2018
1 parent 5c4f6dd commit dd9c18b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gns3server/compute/base_node.py
Expand Up @@ -514,7 +514,7 @@ def _ubridge_send(self, command):
try:
yield from self._ubridge_hypervisor.send(command)
except UbridgeError as e:
raise UbridgeError("{}: {}".format(e, self._ubridge_hypervisor.read_stdout()))
raise UbridgeError("Error while sending command '{}': {}: {}".format(command, e, self._ubridge_hypervisor.read_stdout()))

@locked_coroutine
def _start_ubridge(self):
Expand Down
1 change: 1 addition & 0 deletions gns3server/compute/qemu/qemu_vm.py
Expand Up @@ -894,6 +894,7 @@ def start(self):
af, socktype, proto, _, sa = res
# let the OS find an unused port for the Qemu monitor
with socket.socket(af, socktype, proto) as sock:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(sa)
self._monitor = sock.getsockname()[1]
except OSError as e:
Expand Down
1 change: 1 addition & 0 deletions gns3server/controller/gns3vm/virtualbox_gns3_vm.py
Expand Up @@ -191,6 +191,7 @@ def start(self):
try:
# get a random port on localhost
with socket.socket() as s:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((ip_address, 0))
api_port = s.getsockname()[1]
except OSError as e:
Expand Down
1 change: 1 addition & 0 deletions gns3server/ubridge/hypervisor.py
Expand Up @@ -62,6 +62,7 @@ def __init__(self, project, path, working_dir, host, port=None):
af, socktype, proto, _, sa = res
# let the OS find an unused port for the uBridge hypervisor
with socket.socket(af, socktype, proto) as sock:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(sa)
port = sock.getsockname()[1]
break
Expand Down

0 comments on commit dd9c18b

Please sign in to comment.