Commits

Ruslan Osmanov committed 0568551

Fix: EventBuffer::removeBuffer returned boolean instead of the number of bytes read

Comments (0)

Files changed (4)

 }
 /* }}} */
 
-/* {{{ proto bool EventBuffer::removeBuffer(EventBuffer buf, int len); 
+/* {{{ proto int EventBuffer::removeBuffer(EventBuffer buf, int len); 
  * Moves exactly len bytes from buf to the end of current instance of EventBuffer
  */
 PHP_METHOD(EventBuffer, removeBuffer)
 	PHP_EVENT_FETCH_BUFFER(b_dst, zbuf_dst);
 	PHP_EVENT_FETCH_BUFFER(b_src, zbuf_src);
 
-	if (evbuffer_remove_buffer(b_src->buf, b_dst->buf, (size_t) len)) {
-		RETURN_FALSE;
-	}
+	RETVAL_LONG(evbuffer_remove_buffer(b_src->buf, b_dst->buf, (size_t) len));
 
-	RETVAL_TRUE;
 }
 /* }}} */
 
     <email>osmanov@php.net</email>
     <active>yes</active>
   </lead>
-  <date>2013-03-22</date>
+  <date>2013-03-25</date>
   <!--{{{ Current version -->
   <version>
-    <release>1.5.0</release>
+    <release>1.5.1</release>
     <api>1.5.0</api>
   </version>
   <stability>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes><![CDATA[
-  Fix: uninitialized socket caused segmentation fault in EventBufferEvent methods
-  Del: EventBufferPosition class removed, EventBuffer::search now accepts and returns integers
-  Add: EventBuffer::searchEol method
-  Add: EventUtil::getSocketName method
-  Add: EventListener::getSocketName method
-  Fix: memory leak due to lack of zend_hash_destroy on the ssl context options
-  Add: support of UNIX domain sockets in EventListener::__construct, EventBufferEvent::connect methods
+  Fix: EventBuffer::removeBuffer returned boolean instead of the number of bytes read
   ]]></notes>
   <!--}}}-->
   <!--{{{ Contents -->
         <file role="src" name="05-buffer-pos.phpt"/>
         <file role="src" name="06-timer.phpt"/>
         <file role="src" name="07-listener-error.phpt"/>
+        <file role="src" name="08-buffer.phpt"/>
       </dir>
     </dir>
   </contents>
   </extsrcrelease>
   <!--{{{ changelog-->
   <changelog>
+    <!--{{{ 1.5.1 -->
+    <release>
+      <version>
+        <release>1.5.1</release>
+        <api>1.5.0</api>
+      </version>
+      <stability>
+        <release>stable</release>
+        <api>stable</api>
+      </stability>
+      <license uri="http://www.php.net/license">PHP</license>
+      <notes><![CDATA[
+      Fix: EventBuffer::removeBuffer returned boolean instead of the number of bytes read
+      ]]></notes>
+    </release>
+    <!--}}}-->
     <!--{{{ 1.5.0 -->
     <release>
       <version>
 #ifndef PHP_EVENT_H
 #define PHP_EVENT_H
 
-#define PHP_EVENT_VERSION "1.5.0"
+#define PHP_EVENT_VERSION "1.5.1"
 
 #define PHP_EVENT_SUN_PREFIX "unix:"
 

tests/08-buffer.phpt

+--TEST--
+Check for EventBuffer methods' behaviour
+--FILE--
+<?php
+$s     = "abcdefghijklmnopqrstuvwxyz";
+$s_len = strlen($s);
+$b1    = new EventBuffer();
+$b2    = new EventBuffer();
+
+$b1->add($s);
+
+$tmp = "";
+for ($i = 0, $j = 1; $i < $s_len; $i += 4, ++$j) {
+	if ($b2->removeBuffer($b1, 4)) {
+		$b2->remove($tmp, 32);
+		echo $j, ' ', $tmp == substr($s, $i, 4) ? "ok" : "failed", PHP_EOL;
+	}
+}
+?>
+--EXPECT--
+1 ok
+2 ok
+3 ok
+4 ok
+5 ok
+6 ok
+7 ok
+