Fix DHCP options querying issues
Sometimes, the acquired pair of host and port is stuck into TIME_WAIT status and for reassigning a socket on it, the resources must be freed, which is not immediately possible even after closing the socket. So a reuse address options set on it solves the problem. Change-Id: I1801433b93a4fcd48cd65d047719127f12f1e4e3
This commit is contained in:
parent
0073c7b86b
commit
e33e9bcd22
@ -141,6 +141,8 @@ class DHCPUtilsTests(unittest.TestCase):
|
||||
|
||||
mock_randint.assert_called_once_with(0, 2 ** 32 - 1)
|
||||
mock_socket.assert_called_with(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
mock_socket().setsockopt.assert_called_once_with(
|
||||
socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
mock_socket().bind.assert_called_once_with(('', 68))
|
||||
mock_socket().settimeout.assert_called_once_with(5)
|
||||
mock_socket().connect.assert_called_once_with(('fake host', 67))
|
||||
|
@ -126,6 +126,7 @@ def get_dhcp_options(dhcp_host, requested_options=[], timeout=5.0,
|
||||
options = None
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
try:
|
||||
_bind_dhcp_client_socket(s, max_bind_attempts, bind_retry_interval)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user