diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php index 7f424c51f..da8599f98 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php @@ -80,21 +80,24 @@ class Backend // wait until socket exist for a maximum of $connect_timeout $timeout_wait = $connect_timeout; - while (!file_exists($this->configdSocket)) { + while ( + !file_exists($this->configdSocket) || + ($stream = @stream_socket_client('unix://'.$this->configdSocket, $errorNumber, $errorMessage, $poll_timeout)) === false + ) { sleep(1); $timeout_wait -= 1; if ($timeout_wait <= 0) { - $this->getLogger()->error("failed waiting for configd (doesn't seem to be running)"); + if (file_exists($this->configdSocket)) { + $this->getLogger()->error("Failed to connect to configd socket: $errorMessage while executing " . $event); + return null; + } else { + $this->getLogger()->error("failed waiting for configd (doesn't seem to be running)"); + } return null; } } $resp = ''; - $stream = @stream_socket_client('unix://'.$this->configdSocket, $errorNumber, $errorMessage, $poll_timeout); - if ($stream === false) { - $this->getLogger()->error("Failed to connect to configd socket: $errorMessage while executing " . $event); - return null; - } stream_set_timeout($stream, $poll_timeout); // send command @@ -118,6 +121,9 @@ class Backend if ((time() - $starttime) > $timeout) { $this->getLogger()->error("Timeout (".$timeout.") executing : ".$event); return null; + } elseif (feof($stream)) { + $this->getLogger()->error("Configd disconnected while executing : ".$event); + return null; } }