Commit aff69950 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

multicast: Fix 100% cpu load from select use

Implement select in multicast.py to fix immediate return causing 100% cpu load
See merge request !39
parent f4506017
...@@ -366,12 +366,6 @@ def main(): ...@@ -366,12 +366,6 @@ def main():
R[r] = partial(tunnel_manager.handleServerEvent, r) R[r] = partial(tunnel_manager.handleServerEvent, r)
x.close() x.close()
if config.multicast:
from re6st.multicast import PimDm
pimdm = PimDm()
cleanup.append(pimdm.run(config.iface_list, config.run).stop)
R[pimdm.s_netlink] = pimdm.addInterfaceWhenReady
ip('addr', my_ip + '/%s' % len(subnet), ip('addr', my_ip + '/%s' % len(subnet),
'dev', config.main_interface) 'dev', config.main_interface)
if_rt = ['ip', '-6', 'route', 'del', if_rt = ['ip', '-6', 'route', 'del',
...@@ -458,6 +452,11 @@ def main(): ...@@ -458,6 +452,11 @@ def main():
select_list = [forwarder.select] if forwarder else [] select_list = [forwarder.select] if forwarder else []
if config.console: if config.console:
select_list.append(console.select) select_list.append(console.select)
if config.multicast:
from re6st.multicast import PimDm
pimdm = PimDm()
cleanup.append(pimdm.run(config.iface_list, config.run).stop)
select_list.append(pimdm.select)
select_list += tunnel_manager.select, utils.select select_list += tunnel_manager.select, utils.select
while True: while True:
args = R.copy(), {}, [] args = R.copy(), {}, []
......
...@@ -72,9 +72,6 @@ class PimDm(object): ...@@ -72,9 +72,6 @@ class PimDm(object):
subprocess.call(['pim-dm', '-aimld', ifname]) subprocess.call(['pim-dm', '-aimld', ifname])
def addInterfaceWhenReady(self): def addInterfaceWhenReady(self):
if not self.not_ready_iface_set:
return
data = self.s_netlink.recv(65535) data = self.s_netlink.recv(65535)
unpack = unpacker(data) unpack = unpacker(data)
msg_len, msg_type, flags, seq, pid = unpack("=LHHLL") msg_len, msg_type, flags, seq, pid = unpack("=LHHLL")
...@@ -127,6 +124,10 @@ class PimDm(object): ...@@ -127,6 +124,10 @@ class PimDm(object):
return utils.Popen(['pim-dm', '-config', conf_file_path]) return utils.Popen(['pim-dm', '-config', conf_file_path])
def select(self, r, w, t):
if self.not_ready_iface_set:
r[self.s_netlink] = self.addInterfaceWhenReady
def ifap_iter(ifa): def ifap_iter(ifa):
'''Iterate over linked list of ifaddrs''' '''Iterate over linked list of ifaddrs'''
while ifa: while ifa:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment