summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-06-22 11:34:38 +0200
committerAndrey Andreev <narf@devilix.net>2015-06-22 11:34:38 +0200
commit4e0496e2d6d0bcf654235854d88f71b031e63cb0 (patch)
treed5e1f96a570c0d3efb916df3abea4c8b212bc33c /system/libraries
parentd5784080dcd2c2699bc6fc33a644a1923ba79de8 (diff)
Work-around for https://bugs.php.net/bug.php?id=39598
Fixes #3922
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Email.php22
-rw-r--r--system/libraries/Xmlrpc.php22
2 files changed, 42 insertions, 2 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 66b5803dd..57693e1c7 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -2126,12 +2126,32 @@ class CI_Email {
protected function _send_data($data)
{
$data .= $this->newline;
- for ($written = 0, $length = strlen($data); $written < $length; $written += $result)
+ for ($written = $timestamp = 0, $length = strlen($data); $written < $length; $written += $result)
{
if (($result = fwrite($this->_smtp_connect, substr($data, $written))) === FALSE)
{
break;
}
+ // See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951
+ elseif ($result === 0)
+ {
+ if ($timestamp === 0)
+ {
+ $timestamp = time();
+ }
+ elseif ($timestamp < (time() - $this->smtp_timeout))
+ {
+ $result = FALSE;
+ break;
+ }
+
+ usleep(250000);
+ continue;
+ }
+ else
+ {
+ $timestamp = 0;
+ }
}
if ($result === FALSE)
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 8fbc18f04..55555f56f 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -735,12 +735,32 @@ class XML_RPC_Client extends CI_Xmlrpc
.'Content-Length: '.strlen($msg->payload).$r.$r
.$msg->payload;
- for ($written = 0, $length = strlen($op); $written < $length; $written += $result)
+ for ($written = $timestamp = 0, $length = strlen($op); $written < $length; $written += $result)
{
if (($result = fwrite($fp, substr($op, $written))) === FALSE)
{
break;
}
+ // See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951
+ elseif ($result === 0)
+ {
+ if ($timestamp === 0)
+ {
+ $timestamp = time();
+ }
+ elseif ($timestamp < (time() - $this->timeout))
+ {
+ $result = FALSE;
+ break;
+ }
+
+ usleep(250000);
+ continue;
+ }
+ else
+ {
+ $timestamp = 0;
+ }
}
if ($result === FALSE)