From b282f65db57ee4a0c16416077326d989e879ec53 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 22 Jun 2015 15:14:22 +0200 Subject: [PATCH] wait for configd socket if it's not there yet (https://github.com/opnsense/core/issues/218) --- src/opnsense/mvc/app/library/OPNsense/Core/Backend.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php index b263e6bb4..ef1036904 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php @@ -61,6 +61,16 @@ class Backend $endOfStream = chr(0).chr(0).chr(0); $poll_timeout = 2 ; // poll timeout interval + // wait until socket exist for a maximum of $timeout + $timeout_wait = $timeout; + while (!file_exists($this->configdSocket)) { + sleep(1); + $timeout_wait -= 1; + if ($timeout_wait <= 0) { + throw new \Exception("failed waiting for configd (doesn't seem to be running)"); + } + } + $resp = ""; $stream = stream_socket_client('unix://'.$this->configdSocket, $errorNumber, $errorMessage, $poll_timeout); if ($stream === false) {