Widget Refresh Logic Flawed
I have forked pfSense and resolved this in a feature branch, but need to have a redmine issue for reference when submitting my pull request. Here's a sort of write-up of the issue, and what's been done to resolve it.---
[ /usr/local/www/index.php ]
- The function `executewidget()` is called every second.
- `freq` is defined as the desired number of seconds between each execution of the `ajaxidx`th widget.
- If `ajaxcntr % freq` is equal to 0, the `ajaxidx`th widget will run.
- At the end of `executewidget()`, `ajaxidx` is increased.
- If `ajaxidx` is greater than the number of widgets, it is reset to 0 and `ajaxcntr` is also increased. If `ajaxcntr` is greater than 4096, is it reset to 0.
The end result is that each call of `executewidget()` takes `n` seconds to run, where `n` is the number of widgets on the dashboard, and each widget will only execute every `t` times `executewidget()` is run, resulting in an actual update time of `n * t` seconds.Example, for further illustration:
- Suppose that there are 8 widgets present on the pfSense dashboard, and the Firewall Logs widget is configured to have an "Update interval" of 10 seconds.
- A single call of `executewidget()` takes 8 seconds (1 second per widget * 8 widgets total), and Firewall Logs only refreshes every 10 times `updatewidget()` is called.
- Thus Firewall Logs only refreshes every 8 * 10 seconds, or 80 seconds. This is a bug, and incorrect behavior.
- This will be fixed through the use of a single `for` loop, each time `executewidget()` is called, that "passes over" all widgets and decides on a per-widget basis if they should be executed (based on `ajaxcntr`).