Merge "Build socket list right before select call"
This commit is contained in:
commit
007654a9b6
@ -162,13 +162,12 @@ def _get_lldp_info(interfaces):
|
||||
if not interfaces:
|
||||
return {}
|
||||
|
||||
socks = [interface[1] for interface in interfaces]
|
||||
|
||||
while interfaces:
|
||||
LOG.info('Waiting on LLDP info for interfaces: %(interfaces)s, '
|
||||
'timeout: %(timeout)s', {'interfaces': interfaces,
|
||||
'timeout': CONF.lldp_timeout})
|
||||
|
||||
socks = [interface[1] for interface in interfaces]
|
||||
# rlist is a list of sockets ready for reading
|
||||
rlist, _, _ = select.select(socks, [], [], CONF.lldp_timeout)
|
||||
if not rlist:
|
||||
|
@ -113,7 +113,8 @@ class TestNetutils(test_base.BaseTestCase):
|
||||
sock_mock.side_effect = [sock1, sock2]
|
||||
|
||||
select_mock.side_effect = [
|
||||
([sock1, sock2], [], []),
|
||||
([sock1], [], []),
|
||||
([sock2], [], []),
|
||||
]
|
||||
|
||||
lldp_info = netutils.get_lldp_info(interface_names)
|
||||
@ -131,6 +132,12 @@ class TestNetutils(test_base.BaseTestCase):
|
||||
# 2 interfaces, 2 calls to enter promiscuous mode, 1 to leave
|
||||
self.assertEqual(6, fcntl_mock.call_count)
|
||||
|
||||
expected_calls = [
|
||||
mock.call([sock1, sock2], [], [], cfg.CONF.lldp_timeout),
|
||||
mock.call([sock2], [], [], cfg.CONF.lldp_timeout),
|
||||
]
|
||||
self.assertEqual(expected_calls, select_mock.call_args_list)
|
||||
|
||||
@mock.patch('fcntl.ioctl')
|
||||
@mock.patch('select.select')
|
||||
@mock.patch('socket.socket')
|
||||
|
4
releasenotes/notes/lldp-loop-fdfa584caf33d847.yaml
Normal file
4
releasenotes/notes/lldp-loop-fdfa584caf33d847.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- Fixed incorrect invocation of "select" which could cause LLDP collection
|
||||
to hang under certain conditions.
|
Loading…
Reference in New Issue
Block a user