[前][次][番号順一覧][スレッド一覧]

ruby-changes:27724

From: nobu <ko1@a...>
Date: Sat, 16 Mar 2013 16:28:29 +0900 (JST)
Subject: [ruby-changes:27724] nobu:r39776 (trunk): io.c: max_file_descriptor

nobu	2013-03-16 16:28:20 +0900 (Sat, 16 Mar 2013)

  New Revision: 39776

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39776

  Log:
    io.c: max_file_descriptor
    
    * io.c (max_file_descriptor): rb_atomic_t for ATOMIC_CAS().

  Modified files:
    trunk/io.c

Index: io.c
===================================================================
--- io.c	(revision 39775)
+++ io.c	(revision 39776)
@@ -159,18 +159,19 @@ struct argf { https://github.com/ruby/ruby/blob/trunk/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);
     }
 
-    while (max_file_descriptor < fd) {
-	ATOMIC_CAS(max_file_descriptor, max_file_descriptor, fd);
+    while (max_file_descriptor < afd) {
+	ATOMIC_CAS(max_file_descriptor, max_file_descriptor, afd);
     }
 }
 
@@ -200,8 +201,9 @@ rb_maygvl_fd_fix_cloexec(int fd) https://github.com/ruby/ruby/blob/trunk/io.c#L201
 void
 rb_fd_fix_cloexec(int fd)
 {
+    rb_atomic_t afd = (rb_atomic_t)fd;
     rb_maygvl_fd_fix_cloexec(fd);
-    if (max_file_descriptor < fd) max_file_descriptor = fd;
+    if (max_file_descriptor < afd) max_file_descriptor = afd;
 }
 
 int
@@ -5605,7 +5607,7 @@ void https://github.com/ruby/ruby/blob/trunk/io.c#L5607
 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 */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]