From: Michael M Slusarz Date: Mon, 30 Mar 2009 03:54:35 +0000 (-0600) Subject: More debug information. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=813ce996b8519e5a563438940bfee7d2362b8aa8;p=horde.git More debug information. --- diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Exception.php b/framework/Imap_Client/lib/Horde/Imap/Client/Exception.php index 4068838fa..787cf34d9 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Exception.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Exception.php @@ -53,6 +53,9 @@ class Horde_Imap_Client_Exception extends Exception // Thrown if server denies the network connection. const SERVER_CONNECT = 11; + // Thrown if server response times out. + const SERVER_TIMEOUT = 12; + /** * Define a callback function used to log the exception. Will be passed * a single parameter - a copy of this object. diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index 9bfb58fd4..551ae5e8e 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -3206,7 +3206,10 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base feof($this->_stream)) { $this->_temp['logout'] = true; $this->logout(); - throw new Horde_Imap_Client_Exception('IMAP Server closed the connection unexpectedly.', Horde_Imap_Client_Exception::IMAP_DISCONNECT); + if ($this->_debug) { + fwrite($this->_debug, '[ERROR: IMAP server closed the connection.]' . "\n"); + } + throw new Horde_Imap_Client_Exception('IMAP server closed the connection unexpectedly.', Horde_Imap_Client_Exception::IMAP_DISCONNECT); } $ret = ''; @@ -3240,20 +3243,24 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base } } else { if (empty($this->_temp['buffer_in'])) { - $this->_temp['buffer_in'] = fread($this->_stream, 8192); + if (!($in = fread($this->_stream, 8192))) { + if ($this->_debug) { + fwrite($this->_debug, '[ERROR: IMAP response timed out.]' . "\n"); + } + throw new Horde_Imap_Client_Exception('IMAP response timed out.', Horde_Imap_Client_Exception::SERVER_TIMEOUT); + } + $this->_temp['buffer_in'] = $in; } $ptr = &$this->_temp['buffer_in']; - if ($ptr) { - $pos = strpos($ptr, "\n"); - if ($pos === false) { - $ret = $ptr; - $ptr = ''; - return $ret . $this->_readData(); - } - $ret = substr($ptr, 0, $pos + 1); - $ptr = substr($ptr, $pos + 1); - } + $pos = strpos($ptr, "\n"); + if ($pos === false) { + $ret = $ptr; + $ptr = ''; + return $ret . $this->_readData(); + } + $ret = substr($ptr, 0, $pos + 1); + $ptr = substr($ptr, $pos + 1); } if ($this->_debug) {