diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-10 04:00:33 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-10 04:00:33 +0000 |
commit | 235546ba049fe1e13517d075ec3ba9721af8cb54 (patch) | |
tree | 95308d7b6520823ed052ded2396d07285e487fc2 /io.c | |
parent | bcf12936810465caa1e6b019652ae42bf9fc22f0 (diff) | |
download | ruby-235546ba049fe1e13517d075ec3ba9721af8cb54.tar.gz |
* io.c (rb_update_max_fd): use ATOMIC_CAS because this function
is used from timer thread too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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 |