From c1caf6f5698ed1b945a1015dfbb620f65b4dab51 Mon Sep 17 00:00:00 2001 From: bloqaudio Date: Sun, 13 Sep 2026 11:15:33 -0500 Subject: [PATCH] web: stop the MAC table walk when its section is left The forwarding database is read a page at a time; leaving the MAC table or ports section let the walk carry on through the request queue. Give the walk a generation number that the leave hooks bump, and stop the walk at the next page when it is stale. --- html/app.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/html/app.js b/html/app.js index 91f33b2e..02522413 100644 --- a/html/app.js +++ b/html/app.js @@ -810,7 +810,7 @@ function applyPort(i){ } tabHooks.ports={ enter:function(){statusPoller.start();needPorts(function(){buildPorts();portsMacs()})}, - leave:function(){statusPoller.stop()}, + leave:function(){statusPoller.stop();l2Gen++}, status:portsStatus, }; @@ -1207,11 +1207,12 @@ tabHooks.vlan={ enter:function(){needPorts(function(){buildVlanEdit();vlanRefresh().catch(function(){})})}, }; -var l2Rows=[],l2SortCol="pport",l2SortDir=1; +var l2Rows=[],l2SortCol="pport",l2SortDir=1,l2Gen=0; function l2Load(){ - var seen={},all=[],idx=0,guard=0; + var seen={},all=[],idx=0,guard=0,gen=++l2Gen; function step(){ return getJSON("/l2.json?idx="+idx).then(function(s){ + if(gen!==l2Gen)throw new Error("stale"); if(!s.length)return all; var wrapped=false; s.forEach(function(e){ @@ -1245,7 +1246,7 @@ function l2Fetch(){ return l2Load().then(function(all){ l2Rows=all; l2Render(); - }).catch(function(){$("l2count").textContent=t("l2_failed")}); + }).catch(function(e){if(e.message!=="stale")$("l2count").textContent=t("l2_failed")}); } function l2Render(){ var f=$("l2filter").value.toLowerCase(); @@ -1293,7 +1294,7 @@ $("l2flush").addEventListener("click",function(){ postCmd("l2 forget").then(function(){setTimeout(l2Fetch,500)}).catch(function(){}); }); }); -tabHooks.l2={enter:function(){needPorts(function(){l2Fetch()})}}; +tabHooks.l2={enter:function(){needPorts(function(){l2Fetch()})},leave:function(){l2Gen++}}; function buildMirror(){ var sel=$("mport");