ruby-changes:27635
From: kosaki <ko1@a...>
Date: Sun, 10 Mar 2013 13:00:42 +0900 (JST)
Subject: [ruby-changes:27635] kosaki:r39687 (trunk): * io.c (rb_update_max_fd): use ATOMIC_CAS because this function
kosaki 2013-03-10 13:00:33 +0900 (Sun, 10 Mar 2013) New Revision: 39687 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39687 Log: * io.c (rb_update_max_fd): use ATOMIC_CAS because this function is used from timer thread too. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 39686) +++ ChangeLog (revision 39687) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Mar 7 00:14:51 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * 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@g...> * thread_pthread.c (ARRAY_SIZE): new. Index: io.c =================================================================== --- io.c (revision 39686) +++ io.c (revision 39687) @@ -19,6 +19,7 @@ https://github.com/ruby/ruby/blob/trunk/io.c#L19 #include "id.h" #include <ctype.h> #include <errno.h> +#include "ruby_atomic.h" #define free(x) xfree(x) @@ -158,10 +159,14 @@ void https://github.com/ruby/ruby/blob/trunk/io.c#L159 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/