routertools: Set rx/tx to zero if router gets offline

This has to be done BEFORE the status is set, since otherwise
the selector won't work anymore.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-01-16 00:16:27 +01:00
parent 9e990bc98a
commit 0ce3fa5c2f
1 changed files with 7 additions and 0 deletions

View File

@ -330,6 +330,13 @@ def detect_offline_routers(mysql):
VALUES (%s, %s, 'offline', '')
""",rdata)
mysql.execute("""
UPDATE router_netif AS n
INNER JOIN router AS r ON r.id = n.router
SET n.rx = 0, n.tx = 0
WHERE r.last_contact < %s AND r.status <> 'offline' AND r.status <> 'orphaned'
""",(threshold,))
# Online to Offline has to be updated after other queries!
mysql.execute("""
UPDATE router
SET status = 'offline', clients = 0