Fix issues with macos X dynamips not freeing UDP port

Fix #133
This commit is contained in:
Julien Duponchelle committed 2015-04-03 13:32:07 +02:00
1 parent 1acc9398d5
commit b46e2cf013
3 files changed
+39 -2

No files matched your search

+7 -1
View File
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import socket
import sys
import ipaddress
from aiohttp.web import HTTPConflict
from gns3server.config import Config
@@ -251,14 +252,19 @@ class PortManager:
project.record_udp_port(port)
log.debug("UDP port {} has been reserved".format(port))
def release_udp_port(self, port, project):
def release_udp_port(self, port, project, force_remove=False):
"""
Release a specific UDP port number
:param port: UDP port number
:param project: Project instance
:param force_remove: Force port removal even on Darwnin
"""
# A bug with dynamips on darwin doesn't correctly free the port we free it only when changing project
if sys.platform.startswith("darwin") and force_remove is False:
return
if port in self._used_udp_ports:
self._used_udp_ports.remove(port)
project.remove_udp_port(port)
+1 -1
View File
@@ -361,7 +361,7 @@ class Project:
for port in self._used_tcp_ports.copy():
port_manager.release_tcp_port(port, self)
for port in self._used_udp_ports.copy():
port_manager.release_udp_port(port, self)
port_manager.release_udp_port(port, self, force_remove=True)
@asyncio.coroutine
def commit(self):