From 59104a6ff6c862482eddb9696fd8d22dec89052e Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 14 Sep 2017 08:53:39 -0400 Subject: Move this file_exists test inside the dpinger status check loop and also suppress PHP errors from stream_socket_client() Both are done to avoid a race where the status file can be missing and the status check fails, resulting in an alert/crash report. --- src/etc/inc/gwlb.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/etc') diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc index 9f8ca94..05a0025 100644 --- a/src/etc/inc/gwlb.inc +++ b/src/etc/inc/gwlb.inc @@ -323,13 +323,13 @@ function get_dpinger_status($gwname, $detailed = false) { $proc = $running_processes[$gwname]; unset($running_processes); - if (!file_exists($proc['socket'])) { - log_error("dpinger: status socket {$proc['socket']} not found"); - return false; - } $timeoutcounter = 0; while (true) { - $fp = stream_socket_client("unix://{$proc['socket']}", $errno, $errstr, 10); + if (!file_exists($proc['socket'])) { + log_error("dpinger: status socket {$proc['socket']} not found"); + return false; + } + $fp = @stream_socket_client("unix://{$proc['socket']}", $errno, $errstr, 10); if (!$fp) { log_error(sprintf(gettext('dpinger: cannot connect to status socket %1$s - %2$s (%3$s)'), $proc['socket'], $errstr, $errno)); return false; -- cgit v1.1