svn: /pear/packages/Net_SMTP/trunk/ SMTP.php package.xml
| From: | Jon Parise | Date: | Tue, 28 Sep 2010 05:02:21 +0000 |
| Subject: | svn: /pear/packages/Net_SMTP/trunk/ SMTP.php package.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-60413@lists.php.net to get a copy of this message | ||
jon Tue, 28 Sep 2010 05:02:21 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=303814
Log:
Reduce peak memory usage when sending large files.
Request: 17887
Changed paths:
U pear/packages/Net_SMTP/trunk/SMTP.php
U pear/packages/Net_SMTP/trunk/package.xml
Modified: pear/packages/Net_SMTP/trunk/SMTP.php
===================================================================
--- pear/packages/Net_SMTP/trunk/SMTP.php 2010-09-28 04:15:22 UTC (rev 303813)
+++ pear/packages/Net_SMTP/trunk/SMTP.php 2010-09-28 05:02:21 UTC (rev 303814)
@@ -973,20 +973,48 @@
return $result;
}
}
+ } else {
+ /*
+ * Break up the data by sending one chunk (up to 512k) at a time.
+ * This approach reduces our peak memory usage.
+ */
+ for ($offset = 0; $offset < $size;) {
+ $end = $offset + 512000;
- /* Finally, send the DATA terminator sequence. */
- if (PEAR::isError($result = $this->_send("\r\n.\r\n"))) {
- return $result;
+ /*
+ * Ensure we don't read beyond our data size or span multiple
+ * lines. quotedata() can't properly handle character data
+ * that's split across two line break boundaries.
+ */
+ if ($end >= $size) {
+ $end = $size;
+ } else {
+ for (; $end < $size; $end++) {
+ if ($data[$end] != "\n") {
+ break;
+ }
+ }
+ }
+
+ /* Extract our chunk and run it through the quoting routine. */
+ $chunk = substr($data, $offset, $end - $offset);
+ $this->quotedata($chunk);
+
+ /* If we run into a problem along the way, abort. */
+ if (PEAR::isError($result = $this->_send($chunk))) {
+ return $result;
+ }
+
+ /* Advance the offset to the end of this chunk. */
+ $offset = $end;
}
- } else {
- /* Just send the entire quoted string followed by the DATA
- * terminator. */
- $this->quotedata($data);
- if (PEAR::isError($result = $this->_send($data . "\r\n.\r\n"))) {
- return $result;
- }
}
+ /* Finally, send the DATA terminator sequence. */
+ if (PEAR::isError($result = $this->_send("\r\n.\r\n"))) {
+ return $result;
+ }
+
/* Verify that the data was successfully received by the server. */
if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
return $error;
Modified: pear/packages/Net_SMTP/trunk/package.xml
===================================================================
--- pear/packages/Net_SMTP/trunk/package.xml 2010-09-28 04:15:22 UTC (rev 303813)
+++ pear/packages/Net_SMTP/trunk/package.xml 2010-09-28 05:02:21 UTC (rev 303814)
@@ -19,10 +19,10 @@
<email>chuck@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-03-07</date>
- <time>20:55:00</time>
+ <date>2010-09-02</date>
+ <time>20:01:00</time>
<version>
- <release>1.4.3</release>
+ <release>1.4.4</release>
<api>1.1.3</api>
</version>
<stability>
@@ -30,7 +30,7 @@
<api>stable</api>
</stability>
<license uri="http://www.php.net/license/3_01.txt">PHP
License</license>
- <notes>Adding support for proxy authentication. (Request 17358)
+ <notes>Reduce peak memory usage when sending large files. (Request 17887)
</notes>
<contents>
<dir baseinstalldir="Net" name="/">