Commits

Ruslan Osmanov  committed 9a5cd0a

Fix: pthread.h required for non-threaded php builds
Fix: stupid mistake with returned value of php_stream_can_cast

  • Participants
  • Parent commits 8064f89

Comments (0)

Files changed (3)

   m4_include([libev/libev.m4])
 
   LDFLAGS="$LDFLAGS -lpthread"
-  dnl PHP_ADD_LIBRARY(pthread)
+  PHP_ADD_LIBRARY(pthread)
 
   ev_src="libev/ev.c util.c ev.c watcher.c fe.c pe.c"
   PHP_NEW_EXTENSION(ev, $ev_src, $ext_shared,,$CFLAGS)
 #include "php_ev.h"
 #include "util.h"
 
+#if !defined(_WIN32) && !defined(_MINIX)
+# include <pthread.h>
+#endif
+
 #if HAVE_EV
 
 ZEND_DECLARE_MODULE_GLOBALS(ev)
 		/* PHP stream or PHP socket resource  */
 		if (ZEND_FETCH_RESOURCE_NO_RETURN(stream, php_stream *, ppfd, -1, NULL, php_file_le_stream())) {
 			/* PHP stream */
-			if (php_stream_can_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL)) {
-				if (php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL,
+			if (php_stream_can_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL) == SUCCESS) {
+				if (php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL,
 							(void*) &file_desc, 1) != SUCCESS || file_desc < 0) {
 					return -1;
 				}
-			} else if (php_stream_can_cast(stream, PHP_STREAM_AS_STDIO | PHP_STREAM_CAST_INTERNAL)) {
+			} else if (php_stream_can_cast(stream, PHP_STREAM_AS_STDIO | PHP_STREAM_CAST_INTERNAL) == SUCCESS) {
 				if (php_stream_cast(stream, PHP_STREAM_AS_STDIO | PHP_STREAM_CAST_INTERNAL,
 							(void*) &file_desc, 1) != SUCCESS || file_desc < 0) {
 					return -1;