Project

General

Profile

Bug #6166

requests to diag_system_activity.php can pile up on slow systems

Added by Chris Buechler over 3 years ago. Updated over 3 years ago.

Status:
Resolved
Priority:
Normal
Category:
Web Interface
Target version:
Start date:
04/15/2016
Due date:
% Done:

100%

Estimated time:
Affected Version:
2.3
Affected Architecture:

Description

from mailing list:
https://lists.pfsense.org/pipermail/list/2016-April/009646.html

Just upgraded my embedded pfsense to 2.3.
I have problems getting to the box (web or ssh) it just time outs.
On the web I sometime I get Nginx 504, sometime, just nothing.
Eventually I got logged in, try to check what's going on.
I have open Diagnostics->System Activity page, and start monitoring the network traffic.

There is Java Script that updates the page content every 2.5, but actual response in my case was more then 15 sec.
So I ended up with +20 pending requests to /diag_system_activity.php.

I don't think that setInterval is a good option here. Especially when you don't know how long it will take for the request to complete.

My suggestion is to use setTimeout like this:

<script type="text/javascript">
//<![CDATA[
function getcpuactivity() {
    $.ajax(
        '/diag_system_activity.php',
        {
            method: 'post',
            data: {
                getactivity: 'yes'
            },
            dataType: "html",
            success: function (data) {
                $('#xhrOutput').html(data);
+              setTimeout('getcpuactivity()', 2500);
            },
        }
    );
}

events.push(function() {
-    setInterval('getcpuactivity()', 2500);
+   setTimeout('getcpuactivity()', 2500);
    getcpuactivity();
});
//]]>
</script>

2.2.x and prior used setTimeout there so that seems reasonable but would like sbeaver to confirm.

Associated revisions

Revision 79e348e4 (diff)
Added by Steve Beaver over 3 years ago

Fixed #6166

(cherry picked from commit ebaf36ebe5b6f409887d2352db44aba45bf7e086)

History

#1 Updated by Steve Beaver over 3 years ago

There are a number of problems here. setTimeout is the appropriate function but the call is not quite formatted correctly.

It really needs a mutex to prevent AJAX calls being stacked up.

I will fix these items in a few minutes.

#2 Updated by Steve Beaver over 3 years ago

  • Status changed from Confirmed to Feedback
  • Assignee changed from Steve Beaver to Chris Buechler

AJAX function re-formatted to pfSense style

Added mutex to ensure only one AJAX call is made at a time

#3 Updated by Steve Beaver over 3 years ago

  • % Done changed from 0 to 100

#4 Updated by Chris Buechler over 3 years ago

  • Status changed from Feedback to Resolved

fixed

Also available in: Atom PDF