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

ruby-changes:40099

From: kosaki <ko1@a...>
Date: Sun, 18 Oct 2015 14:42:42 +0900 (JST)
Subject: [ruby-changes:40099] kosaki:r52180 (trunk): * random.c (fill_random_bytes_syscall): don't use GRND_NONBLOCK.

kosaki	2015-10-18 14:42:37 +0900 (Sun, 18 Oct 2015)

  New Revision: 52180

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

  Log:
    * random.c (fill_random_bytes_syscall): don't use GRND_NONBLOCK.
      It is meaningless. If SYS_getrandom(GRND_NONBLOCK) return
      EAGAIN, we eventually call fill_random_bytes_urandom() and
      it block such as SYS_getrandom() without GRND_NONBLOCK.

  Modified files:
    trunk/ChangeLog
    trunk/random.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52179)
+++ ChangeLog	(revision 52180)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Oct 18 13:30:56 2015  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* random.c (fill_random_bytes_syscall): don't use GRND_NONBLOCK.
+	  It is meaningless. If SYS_getrandom(GRND_NONBLOCK) return
+	  EAGAIN, we eventually call fill_random_bytes_urandom() and
+	  it block such as SYS_getrandom() without GRND_NONBLOCK.
+
 Sun Oct 18 13:24:17 2015  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* random.c (fill_random_bytes_syscall): use ATOMIC_SET() for
Index: random.c
===================================================================
--- random.c	(revision 52179)
+++ random.c	(revision 52180)
@@ -518,10 +518,6 @@ fill_random_bytes_syscall(void *seed, si https://github.com/ruby/ruby/blob/trunk/random.c#L518
 #elif defined __linux__ && defined SYS_getrandom
 #include <linux/random.h>
 
-# ifndef GRND_NONBLOCK
-#   define GRND_NONBLOCK 0x0001	/* not defined in musl libc */
-# endif
-
 static int
 fill_random_bytes_syscall(void *seed, size_t size)
 {
@@ -529,7 +525,7 @@ fill_random_bytes_syscall(void *seed, si https://github.com/ruby/ruby/blob/trunk/random.c#L525
     if (try_syscall) {
 	long ret;
 	errno = 0;
-	ret = syscall(SYS_getrandom, seed, size, GRND_NONBLOCK);
+	ret = syscall(SYS_getrandom, seed, size, 0);
 	if (errno == ENOSYS) {
 	    ATOMIC_SET(try_syscall, 0);
 	    return -1;

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

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