From 7ccfe1ba9fbca95683102b3168b48005286cc66e Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 24 Nov 2017 07:54:39 +0000 Subject: [PATCH] web proxy: synchronous service start, no delay, session closed for #1954 --- .../OPNsense/Proxy/Api/ServiceController.php | 12 ++++++++++-- src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt | 10 ++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php index 44e4e2417..1164364d8 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php @@ -45,8 +45,11 @@ class ServiceController extends ApiControllerBase public function startAction() { if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); + $backend = new Backend(); - $response = $backend->configdRun("proxy start", true); + $response = $backend->configdRun("proxy start"); return array("response" => $response); } else { return array("response" => array()); @@ -60,6 +63,9 @@ class ServiceController extends ApiControllerBase public function stopAction() { if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); + $backend = new Backend(); $response = $backend->configdRun("proxy stop"); return array("response" => $response); @@ -75,6 +81,9 @@ class ServiceController extends ApiControllerBase public function restartAction() { if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); + $backend = new Backend(); $response = $backend->configdRun("proxy restart"); return array("response" => $response); @@ -108,7 +117,6 @@ class ServiceController extends ApiControllerBase $status = "unkown"; } - return array("status" => $status); } diff --git a/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt b/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt index 345eb5b65..354d95594 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Proxy/index.volt @@ -169,12 +169,10 @@ POSSIBILITY OF SUCH DAMAGE. draggable: true }); } else { - // request service status after successful save and update status box (wait a few seconds before update) - setTimeout(function(){ - ajaxCall(url="/api/proxy/service/status", sendData={}, callback=function(data,status) { - updateServiceStatusUI(data['status']); - }); - },3000); + // request service status after successful save and update status box + ajaxCall(url="/api/proxy/service/status", sendData={}, callback=function(data,status) { + updateServiceStatusUI(data['status']); + }); } }); });