Ruslan Osmanov avatar Ruslan Osmanov committed af86870 Merge

Merge branch 'develop'

Comments (0)

Files changed (31)

 -------------------------------------------------------------------- 
                   The PHP License, version 3.01
-Copyright (c) 1999 - 2012 The PHP Group. All rights reserved.
+Copyright (c) 1999 - 2013 The PHP Group. All rights reserved.
 -------------------------------------------------------------------- 
 
 Redistribution and use in source and binary forms, with or without
 	HTTP/1.1 301 Moved Permanently
 	Location: http://www.google.co.uk/
 	Content-Type: text/html; charset=UTF-8
-	Date: Sun, 23 Dec 2012 16:08:27 GMT
+	Date: Sun, 23 Dec 2013 16:08:27 GMT
 	Expires: Tue, 22 Jan 2013 16:08:27 GMT
 	Cache-Control: public, max-age=2592000
 	Server: gws
 COPYRIGHT
 =========
 
-Copyright (c) 2012 Ruslan Osmanov <osmanov@php.net>
+Copyright (c) 2013 Ruslan Osmanov <osmanov@php.net>
 
 This project is subject to version 3.01 of the PHP license, that is bundled
 with this package in the file LICENSE, and is available through the
-Handle error when user attempts to attach a signal to different loops
-=====================================================================
-
-There are problems with the following assertion in ev.c:
-
-  assert (("libev: a signal must not be attached to two different loops",
-             !signals [w->signum - 1].loop || signals [w->signum - 1].loop == loop));
-
-Thus, before starting a signal watcher, I have to check it as follows:
-
-	if (signals[(w)->signum - 1].loop
-		&& signals[(w)->signum - 1].loop != my_loop_ptr) {
-		/* error */
-	}
-
-But `signals` declared as static in libev/ev.c:
-
-	static ANSIG signals [EV_NSIG - 1];
-
-So I need my own(MyG()?) array to check this.
-
 Add EvLoop::setInvokePendingCallback(`ev_set_invoke_pending_cb`)?
 =================================================================
 
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 dnl +----------------------------------------------------------------------+
 dnl | PHP Version 5                                                        |
 dnl +----------------------------------------------------------------------+
-dnl | Copyrght (C) 1997-2012 The PHP Group                                 |
+dnl | Copyrght (C) 1997-2013 The PHP Group                                 |
 dnl +----------------------------------------------------------------------+
 dnl | This source file is subject to version 3.01 of the PHP license,      |
 dnl | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 /* }}} */
 
 /* {{{ php_ev_add_property */
-static void php_ev_add_property(HashTable *h, const char *name, size_t name_len, php_ev_read_t read_func, php_ev_write_t write_func TSRMLS_DC) {
+static void php_ev_add_property(HashTable *h, const char *name, size_t name_len, php_ev_read_t read_func, php_ev_write_t write_func, php_ev_get_prop_ptr_ptr_t get_ptr_ptr_func TSRMLS_DC) {
 	php_ev_prop_handler p;
 
-	p.name       = (char *) name;
-	p.name_len   = name_len;
-	p.read_func  = (read_func) ? read_func : php_ev_prop_read_default;
-	p.write_func = (write_func) ? write_func: php_ev_prop_write_default;
+	p.name             = (char *) name;
+	p.name_len         = name_len;
+	p.read_func        = (read_func) ? read_func : php_ev_prop_read_default;
+	p.write_func       = (write_func) ? write_func: php_ev_prop_write_default;
+	p.get_ptr_ptr_func = get_ptr_ptr_func;
 	zend_hash_add(h, name, name_len + 1, &p, sizeof(php_ev_prop_handler), NULL);
 }
 /* }}} */
 /* {{{ php_ev_write_property */
 void php_ev_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC)
 {
-	zval             tmp_member;
-	php_ev_object   *obj;
+	zval                 tmp_member;
+	php_ev_object       *obj;
 	php_ev_prop_handler *hnd;
-	int              ret;
+	int                  ret;
 
 	if (member->type != IS_STRING) {
 	    tmp_member = *member;
 #endif    
 /* }}} */
 
+/* {{{ php_ev_get_property_ptr_ptr */
+static zval **php_ev_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC)
+{
+	php_ev_object        *obj;
+	zval                  tmp_member;
+	zval                **retval     = NULL;
+	php_ev_prop_handler  *hnd;
+	int                   ret        = FAILURE;
+
+	if (member->type != IS_STRING) {
+		tmp_member = *member;
+		zval_copy_ctor(&tmp_member);
+		convert_to_string(&tmp_member);
+		member = &tmp_member;
+	}
+
+	obj = (php_ev_object *) zend_objects_get_address(object TSRMLS_CC);
+
+	if (obj->prop_handler != NULL) {
+		ret = zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member) + 1, (void **) &hnd);
+	}
+
+	if (ret == FAILURE) {
+		retval = zend_get_std_object_handlers()->get_property_ptr_ptr(object, member, key TSRMLS_CC);
+	} else if (hnd->get_ptr_ptr_func) {
+		retval = hnd->get_ptr_ptr_func(obj TSRMLS_CC);
+	}
+
+	if (member == &tmp_member) {
+		zval_dtor(member);
+	}
+
+	return retval;
+}
+/* }}} */
 
 /* {{{ php_ev_object_free_storage 
  * Common Ev object cleaner */
 static PHP_GINIT_FUNCTION(ev)
 {
 	ev_globals->default_loop = NULL;
+	memset(ev_globals->signal_loops, 0, sizeof(ev_globals->signal_loops));
 }
 /* }}} */
 
 	ev_object_handlers.clone_obj            = NULL; /* TODO: add __clone() handler */
 	ev_object_handlers.read_property        = php_ev_read_property;
 	ev_object_handlers.write_property       = php_ev_write_property;
-	ev_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr;
+	ev_object_handlers.get_property_ptr_ptr = php_ev_get_property_ptr_ptr; /* std_hnd->get_property_ptr_ptr */;
 	ev_object_handlers.has_property         = php_ev_has_property;
 #if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
 	ev_object_handlers.get_debug_info       = php_ev_object_get_debug_info;
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 	if (!in_ctor) {
 		/* Factory method mode */
 		if (is_default_loop) {
-
 			if (!*default_loop_ptr_ptr) {
 				loop = ev_default_loop(flags);
 			} else {
 }
 /* }}} */
 
-/* {{{ proto EvLoop EvLoop::defaultLoop([int flags = EVLAG_AUTO[, mixed data = NULL[, double io_interval = 0.[, double timeout_interval = 0.]]]])
+/* {{{ proto EvLoop EvLoop::defaultLoop([int flags = Ev::FLAG_AUTO[, mixed data = NULL[, double io_interval = 0.[, double timeout_interval = 0.]]]])
 */
 PHP_METHOD(EvLoop, defaultLoop)
 {
 }
 /* }}} */
 
-/* {{{ proto EvLoop EvLoop::__construct([int flags = EVLAG_AUTO[[, mixed data = NULL[, double io_interval = 0.[, double timeout_interval = 0.]]]]) */
+/* {{{ proto EvLoop EvLoop::__construct([int flags = Ev::FLAG_AUTO[[, mixed data = NULL[, double io_interval = 0.[, double timeout_interval = 0.]]]]) */
 PHP_METHOD(EvLoop, __construct) 
 {
 	php_ev_loop_object_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU,
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
     int i = 0;                                                                                 \
     while (b[i].name != NULL) {                                                                \
         php_ev_add_property((a), (b)[i].name, (b)[i].name_length,                              \
-                (php_ev_read_t)(b)[i].read_func, (php_ev_write_t)(b)[i].write_func TSRMLS_CC); \
+                (php_ev_read_t)(b)[i].read_func, (php_ev_write_t)(b)[i].write_func,            \
+                (php_ev_get_prop_ptr_ptr_t)(b)[i].get_ptr_ptr_func TSRMLS_CC);                 \
         i++;                                                                                   \
     }                                                                                          \
 }
     <email>osmanov@php.net</email>
     <active>yes</active>
   </lead>
-  <date>2012-12-27</date>
+  <date>2012-01-31</date>
   <!--{{{ Current version -->
   <version>
-    <release>0.2.0</release>
+    <release>0.2.1</release>
     <api>0.2.0</api>
   </version>
   <stability>
     <api>stable</api>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
-  <notes>
-  Change: moved ev_* functions to Ev singleton(due to some issues with reflection)
-  Change: renamed EvLoop::break to EvLoop::stop, and ev_break to Ev::stop
-  Change: moved all constants to Ev class
-  Fix: release version
-  Del: callback parameter from EvLoop constructor/factories
-  Change: watcher createStopped methods made final
-  Change: watcher factory methods made final
-  </notes>
+  <notes><![CDATA[
+  Fix: get_property_ptr_ptr for zval properties was not supoprted. See
+  http://old.nabble.com/Can%27t-get-zval-write-property-handler-working-for-%2B%2B------%2B%2B-and-other-operators-to34843859.html
+  Fix: check for attempts to bind a signal to different event loops
+  ]]></notes>
   <!--}}}-->
   <!--{{{ Contents -->
   <contents>
         <file role="src" name="07_stat.phpt"/>
         <file role="src" name="08_priority.phpt"/>
         <file role="src" name="09_loop_timer.phpt"/>
+        <file role="src" name="10_signal.phpt"/>
       </dir>
       <dir name="libev">
         <file role="doc" name="LICENSE"/>
   </extsrcrelease>
   <!--{{{ changelog-->
   <changelog>
-  <!--{{{ 0.2.0 -->
+  <!--{{{ 0.2.1 -->
   <version>
-    <release>0.2.0</release>
+    <release>0.2.1</release>
     <api>0.2.0</api>
   </version>
   <stability>
     <api>stable</api>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
-  <notes>
+  <notes><![CDATA[
+  Fix: get_property_ptr_ptr for zval properties was not supoprted. See
+  http://old.nabble.com/Can%27t-get-zval-write-property-handler-working-for-%2B%2B------%2B%2B-and-other-operators-to34843859.html
+  Fix: check for attempts to bind a signal to different event loops
+  ]]></notes>
+  <!--}}}-->
+    <!--{{{ 0.2.0 -->
+    <version>
+      <release>0.2.0</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>
   Change: moved ev_* functions to Ev singleton(due to some issues with reflection)
   Change: renamed EvLoop::break to EvLoop::stop, and ev_break to Ev::stop
   Change: moved all constants to Ev class
   Change: watcher createStopped methods made final
   Change: watcher factory methods made final
   </notes>
-  <!--}}}-->
+    <!--}}}-->
     <!--{{{ 0.1.1 (beta) -->
     <release>
       <version>
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 
 /* {{{ EvLoop property handlers */
 
+/* {{{ ev_loop_prop_data_get_ptr_ptr */
+static zval **ev_loop_prop_data_get_ptr_ptr(php_ev_object *obj TSRMLS_DC)
+{
+	PHP_EV_ASSERT(obj->ptr);
+
+	return &PHP_EV_LOOP_OBJECT_FETCH_FROM_OBJECT(obj)->data;
+}
+/* }}} */
+
 /* {{{ ev_loop_prop_data_read  */
 static int ev_loop_prop_data_read(php_ev_object *obj, zval **retval TSRMLS_DC)
 {
 
 /* {{{ EvWatcher property handlers */
 
+
 /* {{{ ev_watcher_prop_is_active_read */
 static int ev_watcher_prop_is_active_read(php_ev_object *obj, zval **retval TSRMLS_DC)
 {
 }
 /* }}} */
 
+/* {{{ ev_watcher_prop_data_get_ptr_ptr */
+static zval **ev_watcher_prop_data_get_ptr_ptr(php_ev_object *obj TSRMLS_DC)
+{
+	PHP_EV_ASSERT(obj->ptr);
+
+	return &PHP_EV_WATCHER_FETCH_FROM_OBJECT(obj)->data;
+}
+/* }}} */
+
 /* {{{ ev_watcher_prop_data_read  */
 static int ev_watcher_prop_data_read(php_ev_object *obj, zval **retval TSRMLS_DC)
 {
 
 /* {{{ ev_loop_property_entries[] */
 const php_ev_property_entry ev_loop_property_entries[] = {
-	{"data",             sizeof("data")             - 1, ev_loop_prop_data_read,             ev_loop_prop_data_write},
-	{"backend",          sizeof("backend")          - 1, ev_loop_prop_backend_read,          NULL},
-	{"is_default_loop",  sizeof("is_default_loop")  - 1, ev_loop_prop_is_default_loop_read,  NULL},
-	{"iteration",        sizeof("iteration")        - 1, ev_loop_prop_iteration_loop_read,   NULL},
-	{"pending",          sizeof("pending")          - 1, ev_loop_prop_pending_loop_read,     NULL},
-	{"io_interval",      sizeof("io_interval")      - 1, ev_loop_prop_io_interval_read,      ev_loop_prop_io_interval_write},
-	{"timeout_interval", sizeof("timeout_interval") - 1, ev_loop_prop_timeout_interval_read, ev_loop_prop_timeout_interval_write},
-	{"depth",            sizeof("depth")            - 1, ev_loop_prop_depth_read,            NULL},
-    {NULL, 0, NULL, NULL}
+	{"data",             sizeof("data")             - 1, ev_loop_prop_data_read,             ev_loop_prop_data_write,             ev_loop_prop_data_get_ptr_ptr},
+	{"backend",          sizeof("backend")          - 1, ev_loop_prop_backend_read,          NULL,                                NULL},
+	{"is_default_loop",  sizeof("is_default_loop")  - 1, ev_loop_prop_is_default_loop_read,  NULL,                                NULL},
+	{"iteration",        sizeof("iteration")        - 1, ev_loop_prop_iteration_loop_read,   NULL,                                NULL},
+	{"pending",          sizeof("pending")          - 1, ev_loop_prop_pending_loop_read,     NULL,                                NULL},
+	{"io_interval",      sizeof("io_interval")      - 1, ev_loop_prop_io_interval_read,      ev_loop_prop_io_interval_write,      NULL},
+	{"timeout_interval", sizeof("timeout_interval") - 1, ev_loop_prop_timeout_interval_read, ev_loop_prop_timeout_interval_write, NULL},
+	{"depth",            sizeof("depth")            - 1, ev_loop_prop_depth_read,            NULL,                                NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 
 /* {{{ ev_watcher_property_entries[] */
 const php_ev_property_entry ev_watcher_property_entries[] = {
-	{"is_active",  sizeof("is_active")  - 1, ev_watcher_prop_is_active_read,  NULL},
-	{"data",       sizeof("data")       - 1, ev_watcher_prop_data_read,       ev_watcher_prop_data_write},
-	{"is_pending", sizeof("is_pending") - 1, ev_watcher_prop_is_pending_read, NULL},
-	{"priority",   sizeof("priority")   - 1, ev_watcher_prop_priority_read,   ev_watcher_prop_priority_write},
-	{NULL, 0, NULL, NULL}
+	{"is_active",  sizeof("is_active")  - 1, ev_watcher_prop_is_active_read,  NULL,                           NULL},
+	{"data",       sizeof("data")       - 1, ev_watcher_prop_data_read,       ev_watcher_prop_data_write,     ev_watcher_prop_data_get_ptr_ptr},
+	{"is_pending", sizeof("is_pending") - 1, ev_watcher_prop_is_pending_read, NULL,                           NULL},
+	{"priority",   sizeof("priority")   - 1, ev_watcher_prop_priority_read,   ev_watcher_prop_priority_write, NULL},
+	{NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 
 /* {{{ ev_io_property_entries[] */
 const php_ev_property_entry ev_io_property_entries[] = {
-	{"fd",     sizeof("fd")     - 1, ev_io_prop_fd_read,     NULL},
-	{"events", sizeof("events") - 1, ev_io_prop_events_read, NULL},
-    {NULL, 0, NULL, NULL}
+	{"fd",     sizeof("fd")     - 1, ev_io_prop_fd_read,     NULL, NULL},
+	{"events", sizeof("events") - 1, ev_io_prop_events_read, NULL, NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 
 /* {{{ ev_timer_property_entries[] */
 const php_ev_property_entry ev_timer_property_entries[] = {
-	{"repeat",    sizeof("repeat")    - 1, ev_timer_prop_repeat_read,    ev_timer_prop_repeat_write},
-	{"remaining", sizeof("remaining") - 1, ev_timer_prop_remaining_read, NULL},
-    {NULL, 0, NULL, NULL}
+	{"repeat",    sizeof("repeat")    - 1, ev_timer_prop_repeat_read,    ev_timer_prop_repeat_write, NULL},
+	{"remaining", sizeof("remaining") - 1, ev_timer_prop_remaining_read, NULL, NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 #if EV_PERIODIC_ENABLE
 /* {{{ ev_periodic_property_entries[] */
 const php_ev_property_entry ev_periodic_property_entries[] = {
-	{"offset",   sizeof("offset")   - 1, ev_periodic_prop_offset_read,   ev_periodic_prop_offset_write},
-	{"interval", sizeof("interval") - 1, ev_periodic_prop_interval_read, ev_periodic_prop_interval_write},
-    {NULL, 0, NULL, NULL}
+	{"offset",   sizeof("offset")   - 1, ev_periodic_prop_offset_read,   ev_periodic_prop_offset_write, NULL},
+	{"interval", sizeof("interval") - 1, ev_periodic_prop_interval_read, ev_periodic_prop_interval_write, NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 #if EV_SIGNAL_ENABLE
 /* {{{ ev_signal_property_entries[] */
 const php_ev_property_entry ev_signal_property_entries[] = {
-	{"signum", sizeof("signum") - 1, ev_signal_prop_signum_read, NULL},
-    {NULL, 0, NULL, NULL}
+	{"signum", sizeof("signum") - 1, ev_signal_prop_signum_read, NULL, NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 #if EV_CHILD_ENABLE
 /* {{{ ev_child_property_entries[] */
 const php_ev_property_entry ev_child_property_entries[] = {
-	{"pid",     sizeof("pid")     - 1, ev_child_prop_pid_read,     NULL},
-	{"rpid",    sizeof("rpid")    - 1, ev_child_prop_rpid_read,    NULL},
-	{"rstatus", sizeof("rstatus") - 1, ev_child_prop_rstatus_read, NULL},
-    {NULL, 0, NULL, NULL}
+	{"pid",     sizeof("pid")     - 1, ev_child_prop_pid_read,     NULL, NULL},
+	{"rpid",    sizeof("rpid")    - 1, ev_child_prop_rpid_read,    NULL, NULL},
+	{"rstatus", sizeof("rstatus") - 1, ev_child_prop_rstatus_read, NULL, NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 #if EV_STAT_ENABLE
 /* {{{ ev_stat_property_entries[] */
 const php_ev_property_entry ev_stat_property_entries[] = {
-	{"path",     sizeof("path")     - 1, ev_stat_prop_path_read,     NULL},
-	{"interval", sizeof("interval") - 1, ev_stat_prop_interval_read, NULL},
-    {NULL, 0, NULL, NULL}
+	{"path",     sizeof("path")     - 1, ev_stat_prop_path_read,     NULL, NULL},
+	{"interval", sizeof("interval") - 1, ev_stat_prop_interval_read, NULL, NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
 #if EV_EMBED_ENABLE
 /* {{{ ev_embed_property_entries[] */
 const php_ev_property_entry ev_embed_property_entries[] = {
-	{"other", sizeof("other") - 1, ev_embed_prop_other_read, NULL},
-    {NULL, 0, NULL, NULL}
+	{"other", sizeof("other") - 1, ev_embed_prop_other_read, NULL, NULL},
+    {NULL, 0, NULL, NULL, NULL}
 };
 /* }}} */
 
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 PHP_RSHUTDOWN_FUNCTION(ev);
 PHP_MINFO_FUNCTION(ev);
 
+/* Max. signum supported */
+#ifndef EV_NSIG
+# define EV_NSIG 32
+#endif
+
 ZEND_BEGIN_MODULE_GLOBALS(ev)
 	zval *default_loop;
+	/* Helps to prevent binding of different `signum's to a loop */
+	struct ev_loop *signal_loops[EV_NSIG - 1];
 ZEND_END_MODULE_GLOBALS(ev)
 ZEND_EXTERN_MODULE_GLOBALS(ev)
 
 extern zend_module_entry ev_module_entry;
 #define phpext_ev_ptr &ev_module_entry
 
-#define PHP_EV_VERSION "0.2.0"
+#define PHP_EV_VERSION "0.2.1"
 
 #endif /* PHP_EV_H */
 
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 		return;
 	}
 
+	PHP_EV_CHECK_SIGNUM(signum);
+
 	if (ctor) {
 		self = getThis();
 	} else {
 	o_self->ptr = (void *) w;
 
 	if (start) {
-		PHP_EV_WATCHER_START(ev_signal, w);
+		PHP_EV_SIGNAL_START(w);
 	}
 }
 /* }}} */
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |

tests/10_signal.phpt

+--TEST--
+Check for EvSignal functionality
+--SKIPIF--
+<?php
+if (!extension_loaded("pcntl")) print "skip pcntl extension is not loaded";
+if (!extension_loaded("posix")) print "skip posix extension is not loaded";
+?>
+--FILE--
+<?php 
+error_reporting(0);
+
+echo "ok 1\n";
+
+$sig1 = new EvSignal(SIGUSR1, function () { echo "ok 8\n"; });
+
+echo "ok 2\n";
+
+$loop = new EvLoop();
+
+echo "ok 3\n";
+
+$usr2_1 = $loop->signal(SIGUSR2, function ($w) { echo "ok 6\n"; $w->stop(); });
+$usr2_2 = $loop->signal(SIGUSR1, function () { echo "not ok 6\n"; });
+
+$sig2 = new EvSignal(SIGUSR2, function () { echo "not ok 8\n"; });
+
+echo "ok 4\n";
+
+posix_kill(posix_getpid(), SIGUSR1);
+posix_kill(posix_getpid(), SIGUSR2);
+
+echo "ok 5\n";
+
+$loop->run();
+
+echo "ok 7\n";
+
+Ev::run(Ev::RUN_ONCE);
+
+echo "ok 9\n";
+
+// Re-bind
+$usr2 = new EVSignal(SIGUSR2, function () { echo "ok 11\n"; });
+$sig1->stop();
+$usr1_2 = $loop->signal(SIGUSR1, function () { echo "ok 13\n"; });
+
+echo "ok 10\n";
+
+posix_kill(posix_getpid(), SIGUSR2);
+
+Ev::run(Ev::RUN_NOWAIT);
+
+echo "ok 12\n";
+
+posix_kill(posix_getpid(), SIGUSR1);
+
+$loop->run(Ev::RUN_NOWAIT);
+
+echo "ok 14\n";
+?>
+--EXPECT--
+ok 1
+ok 2
+ok 3
+ok 4
+ok 5
+ok 6
+ok 7
+ok 8
+ok 9
+ok 10
+ok 11
+ok 12
+ok 13
+ok 14
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 /* php_ev_loop pointer is stored in php_ev_object.ptr struct member */
 
 typedef struct php_ev_loop {
-	struct ev_loop        *loop;
-	zval                  *data;                       /* User custom data attached to event loop                  */
-	double                 io_collect_interval;        /* If > 0, ev_io_collect_interval is called internally      */
-	double                 timeout_collect_interval;   /* If > 0, ev_timeout_collect_interval is called internally */
-	struct ev_watcher     *w;                          /* Head of linked list                                      */
+	struct ev_loop    *loop;
+	zval              *data;                       /* User custom data attached to event loop                  */
+	double             io_collect_interval;        /* If > 0, ev_io_collect_interval is called internally      */
+	double             timeout_collect_interval;   /* If > 0, ev_timeout_collect_interval is called internally */
+	struct ev_watcher *w;                          /* Head of linked list                                      */
 } php_ev_loop;
 
 /* Property handlers */
 
 typedef int (*php_ev_read_t)(php_ev_object  *obj, zval **retval TSRMLS_DC);
 typedef int (*php_ev_write_t)(php_ev_object *obj, zval *newval  TSRMLS_DC);
+#if 0
+typedef zval **(*php_ev_get_prop_ptr_ptr_t)(php_ev_object *obj, zval *object, zval *member, const struct _zend_literal *key TSRMLS_DC);
+#endif
+typedef zval **(*php_ev_get_prop_ptr_ptr_t)(php_ev_object *obj TSRMLS_DC);
 
 /* Property of an Ev* class */
 
 typedef struct php_ev_property_entry {
-	const char     *name;
-	size_t          name_length;
-	php_ev_read_t   read_func;
-	php_ev_write_t  write_func;
+	const char                *name;
+	size_t                     name_length;
+	php_ev_read_t              read_func;
+	php_ev_write_t             write_func;
+	php_ev_get_prop_ptr_ptr_t  get_ptr_ptr_func;
 } php_ev_property_entry;
 
 typedef struct {
-	char           *name;
-	size_t          name_len;
-	php_ev_read_t   read_func;
-	php_ev_write_t  write_func;
+	char                      *name;
+	size_t                     name_len;
+	php_ev_read_t              read_func;
+	php_ev_write_t             write_func;
+	php_ev_get_prop_ptr_ptr_t  get_ptr_ptr_func;
 } php_ev_prop_handler;
 
 
-/* Type for EvLoop::once(i.e. ev_once) arg.
- * We've no other way to call userspace callback */
-typedef struct php_ev_once_arg {
-	zval                    *data;         /* user custom data for EvLoop::once() */
-	zend_fcall_info         *fci;          /* fci and fcc serve callbacks         */
-	zend_fcall_info_cache   *fcc;
-	/* Thread context. With it we are getting rid of need
-	 * to call the heavy TSRMLS_FETCH() */
-#ifdef ZTS
-	void                  ***thread_ctx;
-#endif
-} php_ev_once_arg;
-
 #endif /* PHP_EV_TYPES_H */
 
 /*
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
    +----------------------------------------------------------------------+
 */
 
+#if 0
 #include "embed.h"
 #include "priv.h"
 #include "watcher.h"
+#endif
+#include "php_ev.h"
 
 /* Defined in ev.c */
 extern zend_class_entry *ev_loop_class_entry_ptr;
 #endif
 #if EV_SIGNAL_ENABLE
 		case EV_SIGNAL:
-			PHP_EV_WATCHER_START(ev_signal, watcher);
+			PHP_EV_SIGNAL_START((ev_signal *) watcher);
 			break;
 #endif
 #if EV_CHILD_ENABLE
 #endif
 #if EV_SIGNAL_ENABLE
 		case EV_SIGNAL:
-			PHP_EV_WATCHER_STOP(ev_signal, watcher);
+			PHP_EV_SIGNAL_STOP((ev_signal *) watcher);
 			break;
 #endif
 #if EV_CHILD_ENABLE
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2012 The PHP Group                                |
+   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |
 
 #define PHP_EV_CHECK_SIGNAL_CAN_START(w)                                                   \
     do {                                                                                   \
-        /* Pulled this part from EV module of Perl */                                      \
-        if (signals [(w)->signum - 1].loop                                                 \
-                && signals [(w)->signum - 1].loop != php_ev_watcher_loop_ptr(w)) {         \
+        struct ev_loop *tmp_loop = MyG(signal_loops[(w)->signum - 1]);                     \
+        if (tmp_loop && tmp_loop != php_ev_watcher_loop_ptr(w)) {                          \
             php_error_docref(NULL TSRMLS_CC, E_WARNING,                                    \
                     "Can't start signal watcher, signal %d already "                       \
-                    "registered in another loop", w->signum);                              \
+                    "registered for another loop", (w)->signum);                           \
+            return;                                                                        \
         }                                                                                  \
     } while (0)
 
 #define PHP_EV_SIGNAL_START(w)                                                             \
     do {                                                                                   \
-        PHP_EV_CHECK_SIGNAL_CAN_START(w);                                                  \
-        PHP_EV_WATCHER_START(ev_signal, w);                                                \
+        PHP_EV_CHECK_SIGNAL_CAN_START(((ev_signal *) (w)));                                \
+        MyG(signal_loops[(w)->signum - 1]) = php_ev_watcher_loop_ptr((w));                 \
+        PHP_EV_WATCHER_START(ev_signal, (w));                                              \
+    } while (0)
+
+#define PHP_EV_SIGNAL_STOP(w)                                                              \
+    do {                                                                                   \
+        MyG(signal_loops[(w)->signum - 1]) = 0;                                            \
+        PHP_EV_WATCHER_STOP(ev_signal, (w));                                               \
     } while (0)
 
 #define PHP_EV_SIGNAL_RESET(w, seta)                                                       \
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.