Ruslan Osmanov avatar Ruslan Osmanov committed 5cd7496

Add: pthread_atfork to handle loop forks

Comments (0)

Files changed (2)

 
 /* {{{ Private functions */
 
+/* {{{ php_ev_default_fork */
+static void php_ev_default_fork(void)
+{
+	ev_loop_fork(EV_DEFAULT_UC);
+}
+/* }}} */
+
 /* {{{ php_ev_prop_read_default */
 static int php_ev_prop_read_default(php_ev_object *obj, zval **retval TSRMLS_DC)
 {
 	PHP_EV_REGISTER_LONG_CONSTANT(EV_CUSTOM);
 	PHP_EV_REGISTER_LONG_CONSTANT(EV_ERROR);
 
+#if !defined(_WIN32) && !defined(_MINIX)
+	pthread_atfork(0, 0, php_ev_default_fork);
+#endif
+
 	return SUCCESS;
 }
 /* }}} */
 }
 /* }}} */
 
-
 /* }}} */
 
 #endif /* HAVE_EV */
 
 /* {{{ ev_functions[] */
 const zend_function_entry ev_functions[] = {
-	PHP_FE(ev_supported_backends, arginfo_ev__void)
+	PHP_FE(ev_supported_backends,   arginfo_ev__void)
 	PHP_FE(ev_recommended_backends, arginfo_ev__void)
-	PHP_FE(ev_embeddable_backends, arginfo_ev__void)
-	PHP_FE(ev_sleep, arginfo_ev_sleep)
-	PHP_FE(ev_time, arginfo_ev__void)
-	PHP_FE(ev_feed_signal, arginfo_ev_feed_signal)
+	PHP_FE(ev_embeddable_backends,  arginfo_ev__void)
+	PHP_FE(ev_sleep,                arginfo_ev_sleep)
+	PHP_FE(ev_time,                 arginfo_ev__void)
+	PHP_FE(ev_feed_signal,          arginfo_ev_feed_signal)
 
 	{NULL, NULL, NULL}
 };
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.