Module: nagvis Branch: master Commit: 1bc0b4c1cf10640ae510f8314094a756ba7533f4 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=1bc0b4c1cf10640ae510f8314094a756ba7533f4
Author: Lars Michelsen <[email protected]> Date: Sat Oct 2 14:16:31 2010 +0200 MKLivestatus backend: Added better error handling to socket writes in --- .../core/classes/GlobalBackendmklivestatus.php | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/share/server/core/classes/GlobalBackendmklivestatus.php b/share/server/core/classes/GlobalBackendmklivestatus.php index b49e755..3d615e4 100644 --- a/share/server/core/classes/GlobalBackendmklivestatus.php +++ b/share/server/core/classes/GlobalBackendmklivestatus.php @@ -213,15 +213,21 @@ class GlobalBackendmklivestatus implements GlobalBackendInterface { // Query to get a json formated array back // Use KeepAlive with fixed16 header - socket_write($this->SOCKET, $query . "OutputFormat:json\nKeepAlive: on\nResponseHeader: fixed16\n\n"); + $oldLevel = error_reporting(0); + $write = socket_write($this->SOCKET, $query . "OutputFormat:json\nKeepAlive: on\nResponseHeader: fixed16\n\n"); + error_reporting($oldLevel); + if($write === false) + throw new BackendConnectionProblem(GlobalCore::getInstance()->getLang()->getText('Problem while writing to socket [SOCKET] in backend [BACKENDID]: [MSG]', + Array('BACKENDID' => $this->backendId, 'SOCKET' => $this->socketPath, 'MSG' => socket_strerror(socket_last_error($this->SOCKET))))); + // Read 16 bytes to get the status code and body size $read = $this->readSocket(16); // Catch problem while reading - if($read === false) { - throw new BackendConnectionProblem(GlobalCore::getInstance()->getLang()->getText('Problem while reading from socket [SOCKET] in backend [BACKENDID]: [MSG]', Array('BACKENDID' => $this->backendId, 'SOCKET' => $this->socketPath, 'MSG' => socket_strerror(socket_last_error($this->SOCKET))))); - } + if($read === false) + throw new BackendConnectionProblem(GlobalCore::getInstance()->getLang()->getText('Problem while reading from socket [SOCKET] in backend [BACKENDID]: [MSG]', + Array('BACKENDID' => $this->backendId, 'SOCKET' => $this->socketPath, 'MSG' => socket_strerror(socket_last_error($this->SOCKET))))); // Extract status code $status = substr($read, 0, 3); ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
