Commit d7a15df1 authored by oni's avatar oni

Jetzt auch mit richtigen locks! \o/

parent dee4a4e8
......@@ -24,7 +24,9 @@ def alfred_cleaner(config, alfred_channels,batadv,alfredLock,batadvLock):
count = 0
while True:
count += 1
#print("Aquire alfed")
alfredLock.acquire(True)
#print("Nice!")
for channel in alfred_channels.keys():
to_del = []
for node in alfred_channels[channel].keys():
......@@ -46,7 +48,9 @@ def alfred_cleaner(config, alfred_channels,batadv,alfredLock,batadvLock):
f.close()
alfredLock.release()
#print("Aquireing bamän..")
batadvLock.acquire(True)
#print("ok =)")
new = list(filter(lambda entry: time.time() - entry['time'] > config['update_interval'] * 2, batadv))
for entry in new:
batadv.remove(entry)
......@@ -55,6 +59,8 @@ def alfred_cleaner(config, alfred_channels,batadv,alfredLock,batadvLock):
output = ""
for entry in batadv:
output += entry['data']+'\n'
print("writing data")
#print(output)
f.write(output)
f.close()
batadvLock.release()
......@@ -79,8 +85,14 @@ def alfred_server(config, alfred_channels,batadv_data,alfredLock,batadvLock):
mac = node['node_id']
mac = ':'.join([mac[i:i+2] for i in range(0,len(mac),2)])
elif 'network' in node: #fallback
mac = node['network']['mac']
try:
mac = node['network']['mac']
except KeyError as e:
print(node)
alfredLock.release()
continue
else: #fuck you
alfredLock.release()
continue
if str(channel) not in alfred_channels:
alfred_channels[str(channel)] = {mac : node}
......
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