Skip to content

Commit

Permalink
Bug #18281 Socket.php errors when sending large emails through Pear Mail
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/Net_Socket/trunk@322718 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
CloCkWeRX committed Jan 25, 2012
1 parent c16f70a commit a2c3dee
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Net/Socket.php
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit a2c3dee

Please sign in to comment.