ruby-changes:28438
From: nagachika <ko1@a...>
Date: Sat, 27 Apr 2013 02:31:50 +0900 (JST)
Subject: [ruby-changes:28438] nagachika:r40490 (ruby_2_0_0): merge revision(s) 39687,39776,40438: [Backport #8064]
nagachika 2013-04-27 02:31:33 +0900 (Sat, 27 Apr 2013) New Revision: 40490 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40490 Log: merge revision(s) 39687,39776,40438: [Backport #8064] * io.c (rb_update_max_fd): use ATOMIC_CAS because this function is used from timer thread too. * io.c (rb_fd_fix_cloexec): use rb_update_max_fd(). Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/io.c branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 40489) +++ ruby_2_0_0/ChangeLog (revision 40490) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Sat Apr 27 02:12:14 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * io.c (rb_fd_fix_cloexec): use rb_update_max_fd(). + +Sat Apr 27 02:12:14 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * io.c (rb_update_max_fd): use ATOMIC_CAS because this function + is used from timer thread too. + Sat Apr 27 01:57:43 2013 CHIKANAGA Tomoyuki <nagachika@r...> * configure.in: use quadrigraphs. workaround for autoconf 2.64. Index: ruby_2_0_0/io.c =================================================================== --- ruby_2_0_0/io.c (revision 40489) +++ ruby_2_0_0/io.c (revision 40490) @@ -19,6 +19,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L19 #include "id.h" #include <ctype.h> #include <errno.h> +#include "ruby_atomic.h" #define free(x) xfree(x) @@ -158,15 +159,20 @@ struct argf { https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L159 int8_t init_p, next_p, binmode; }; -static int max_file_descriptor = NOFILE; +static rb_atomic_t max_file_descriptor = NOFILE; void rb_update_max_fd(int fd) { struct stat buf; + rb_atomic_t afd = (rb_atomic_t)fd; + 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 < afd) { + ATOMIC_CAS(max_file_descriptor, max_file_descriptor, afd); + } } void @@ -196,7 +202,7 @@ void https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L202 rb_fd_fix_cloexec(int fd) { rb_maygvl_fd_fix_cloexec(fd); - if (max_file_descriptor < fd) max_file_descriptor = fd; + rb_update_max_fd(fd); } int @@ -5607,7 +5613,7 @@ void https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L5613 rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds) { int fd, ret; - int max = max_file_descriptor; + int max = (int)max_file_descriptor; #ifdef F_MAXFD /* F_MAXFD is available since NetBSD 2.0. */ ret = fcntl(0, F_MAXFD); /* async-signal-safe */ Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 40489) +++ ruby_2_0_0/version.h (revision 40490) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-04-27" -#define RUBY_PATCHLEVEL 174 +#define RUBY_PATCHLEVEL 175 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 4 Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r39687,39776,40438 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/