diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | io.c | 7 |
2 files changed, 11 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Thu Mar 7 00:14:51 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * io.c (rb_update_max_fd): use ATOMIC_CAS because this function + is used from timer thread too. + Wed Mar 6 23:30:21 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> * thread_pthread.c (ARRAY_SIZE): new. @@ -19,6 +19,7 @@ #include "id.h" #include <ctype.h> #include <errno.h> +#include "ruby_atomic.h" #define free(x) xfree(x) @@ -158,10 +159,14 @@ void rb_update_max_fd(int fd) { struct stat buf; + if (fstat(fd, &buf) != 0 && errno == EBADF) { rb_bug("rb_update_max_fd: invalid fd (%d) given.", fd); } - if (max_file_descriptor < fd) max_file_descriptor = fd; + + while (max_file_descriptor < fd) { + ATOMIC_CAS(max_file_descriptor, max_file_descriptor, fd); + } } void |