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

ruby-changes:46474

From: normal <ko1@a...>
Date: Sun, 7 May 2017 16:38:35 +0900 (JST)
Subject: [ruby-changes:46474] normal:r58590 (trunk): io.c (do_fcntl): update max FD for F_DUPFD_CLOEXEC, too

normal	2017-05-07 16:38:30 +0900 (Sun, 07 May 2017)

  New Revision: 58590

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58590

  Log:
    io.c (do_fcntl): update max FD for F_DUPFD_CLOEXEC, too
    
    Somebody may pass 1030 (the value of F_DUPFD_CLOEXEC) to IO#fcntl
    because they copied code from somewhere else.  Ensure we know
    about FDs created that way.
    
    * io.c (do_fcntl): update max FD for F_DUPFD_CLOEXEC, too

  Modified files:
    trunk/io.c
Index: io.c
===================================================================
--- io.c	(revision 58589)
+++ io.c	(revision 58590)
@@ -9480,11 +9480,17 @@ do_fcntl(int fd, int cmd, long narg) https://github.com/ruby/ruby/blob/trunk/io.c#L9480
     arg.narg = narg;
 
     retval = (int)rb_thread_io_blocking_region(nogvl_fcntl, &arg, fd);
+    if (retval != -1) {
+	switch (cmd) {
 #if defined(F_DUPFD)
-    if (retval != -1 && cmd == F_DUPFD) {
-	rb_update_max_fd(retval);
-    }
+	case F_DUPFD:
+#endif
+#if defined(F_DUPFD_CLOEXEC)
+	case F_DUPFD_CLOEXEC:
 #endif
+	    rb_update_max_fd(retval);
+	}
+    }
 
     return retval;
 }

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

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