summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-10 04:00:33 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-10 04:00:33 +0000
commit235546ba049fe1e13517d075ec3ba9721af8cb54 (patch)
tree95308d7b6520823ed052ded2396d07285e487fc2 /io.c
parentbcf12936810465caa1e6b019652ae42bf9fc22f0 (diff)
* 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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/io.c b/io.c
index 1ec1e8da95..ed8ae96d54 100644
--- a/io.c
+++ b/io.c
@@ -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