Commits

Ruslan Osmanov committed 5cd7496

Add: pthread_atfork to handle loop forks

  • Participants
  • Parent commits 05c3e90

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}
 };