Skip to content
Browse files

Bug #18281 Socket.php errors when sending large emails through Pear Mail

git-svn-id: http://svn.php.net/repository/pear/packages/Net_Socket/trunk@322718 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent c16f70a commit a2c3deec739dfb08f9ac673f1d541e278efdc775 @CloCkWeRX CloCkWeRX committed Jan 25, 2012
Showing with 15 additions and 3 deletions.
  1. +15 −3 Net/Socket.php
View
18 Net/Socket.php
@@ -360,9 +360,10 @@ function read($size)
*
* @access public
* @return mixed If the socket is not connected, returns an instance of
- * PEAR_Error
- * If the write succeeds, returns the number of bytes written
+ * PEAR_Error.
+ * If the write succeeds, returns the number of bytes written.
* If the write fails, returns false.
+ * If the socket times out, returns an instance of PEAR_Error.
*/
function write($data, $blocksize = null)
{
@@ -371,7 +372,13 @@ function write($data, $blocksize = null)
}
if (is_null($blocksize) && !OS_WINDOWS) {
- return @fwrite($this->fp, $data);
+ $r = @fwrite($this->fp, $data);
+ // Check for timeout:
+ $meta_data = $this->getStatus();
+ if (!empty($meta_data['timed_out'])) {
+ return $this->raiseError('timed out');
+ }
+ return $r;
} else {
if (is_null($blocksize)) {
$blocksize = 1024;
@@ -381,6 +388,11 @@ function write($data, $blocksize = null)
$size = strlen($data);
while ($pos < $size) {
$written = @fwrite($this->fp, substr($data, $pos, $blocksize));
+ // Check for timeout:
+ $meta_data = $this->getStatus();
+ if (!empty($meta_data['timed_out'])) {
+ return $this->raiseError('timed out');
+ }
if (!$written) {
return $written;
}

0 comments on commit a2c3dee

Please sign in to comment.
Something went wrong with that request. Please try again.