From a93ecef8cd9be3fc72f25786636edb8f4f9261a5 Mon Sep 17 00:00:00 2001 From: abluchet Date: Fri, 28 Jul 2017 14:35:32 +0200 Subject: [PATCH] fix wrong cpu usage --- app/js/main.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/js/main.js b/app/js/main.js index 44d75747..b5fbb789 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -1137,7 +1137,7 @@ var App = (function(App, undefined) { App.relaunchApplication = function(didFinalize) { console.log("App.relaunchApplication: " + didFinalize); - // For light wallet, we want to make sure that everything is cleaned properly before restarting.. + // For light wallet, we want to make sure that everything is cleaned properly before restarting.. if (global.lightWallet && App.windowIsReady && !didFinalize) { console.log("Sending stopCcurl message to renderer"); win.webContents.send("stopCcurl", {"relaunch": true}); @@ -1389,10 +1389,23 @@ var App = (function(App, undefined) { } App.stopTrackingCPU = function() { - if (cpuTrackInterval) { - clearInterval(cpuTrackInterval); + if (!cpuTrackInterval) { + App.updateStatusBar({"cpu": ""}); + return + } + + clearInterval(cpuTrackInterval); + + var pid; + if (settings.lightWallet == 1) { + pid = rendererPid; + } else if (server && server.pid) { + pid = server.pid; + } + + if (pid) { + pusage.unmonitor(pid); } - App.updateStatusBar({"cpu": ""}); } App.trackCPU = function() { @@ -1412,8 +1425,6 @@ var App = (function(App, undefined) { App.updateStatusBar({"cpu": Math.round(stat.cpu).toFixed(2)}); } }); - - pusage.unmonitor(pid); } else { console.log("Track CPU: No server PID"); if (cpuTrackInterval) {