Commits

Ruslan Osmanov committed a2d6837

Fix: bug #64788

Comments (0)

Files changed (4)

     <email>osmanov@php.net</email>
     <active>yes</active>
   </lead>
-  <date>2013-04-22</date>
+  <date>2013-07-16</date>
   <!--{{{ Current version -->
   <version>
-    <release>0.2.5</release>
+    <release>0.2.6</release>
     <api>0.2.0</api>
   </version>
   <stability>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes><![CDATA[
-  Fix: build error due to return (void) from function returning int on Mac OS X
+  Fix: bug #64788 where var_dump() of EvIo watcher caused disfunction of whole event loop
   ]]></notes>
   <!--}}}-->
   <!--{{{ Contents -->
         <file role="src" name="08_priority.phpt"/>
         <file role="src" name="09_loop_timer.phpt"/>
         <file role="src" name="10_signal.phpt"/>
+        <file role="src" name="bug64788.phpt"/>
       </dir>
       <dir name="libev">
         <file role="doc" name="LICENSE"/>
   </extsrcrelease>
   <!--{{{ changelog-->
   <changelog>
+    <!--{{{ Current version -->
+    <release>
+      <version>
+        <release>0.2.6</release>
+        <api>0.2.0</api>
+      </version>
+      <stability>
+        <release>stable</release>
+        <api>stable</api>
+      </stability>
+      <license uri="http://www.php.net/license">PHP</license>
+      <notes><![CDATA[
+  Fix: bug #64788 where var_dump() of EvIo watcher caused disfunction of whole event loop
+  ]]></notes>
+    </release>
+    <!--}}}-->
     <!--{{{ 0.2.5 -->
     <version>
       <release>0.2.5</release>
 
 #include "php_ev.h"
 #include "watcher.h"
+#include <fcntl.h>
 
 static inline void php_ev_prop_write_zval(zval **ppz, const zval *value)
 {
 static int ev_io_prop_fd_read(php_ev_object *obj, zval **retval TSRMLS_DC)
 {
 	ev_io *io_watcher = (ev_io *) PHP_EV_WATCHER_FETCH_FROM_OBJECT(obj);
+
+	if (io_watcher->fd <= 0 || fcntl(io_watcher->fd, F_GETFD) == -1) {
+		// Invalid fd
+		ALLOC_INIT_ZVAL(*retval); // NULL
+		return SUCCESS;
+	}
+
 	php_stream *stream = php_stream_fopen_from_fd(io_watcher->fd, "r", NULL);
 
 	if (stream) {
 extern zend_module_entry ev_module_entry;
 #define phpext_ev_ptr &ev_module_entry
 
-#define PHP_EV_VERSION "0.2.5"
+#define PHP_EV_VERSION "0.2.6"
 
 #endif /* PHP_EV_H */
 

tests/bug64788.phpt

+--TEST--
+Check for bug #64788
+--FILE--
+<?php
+$io = new EvIo(STDIN, Ev::READ, function ($watcher, $revents) {
+	echo "ok 1";
+	$watcher->stop();
+	Ev::stop();
+});
+$dump = var_export($io, 1);
+$timer = new EvTimer(0.2, 0, function ($w, $r) use ($io) {
+	echo "ok 2";
+	$io->stop();
+	Ev::stop();
+});
+Ev::run();
+?>
+--EXPECTF--
+ok %d
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.