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

ruby-changes:40101

From: kosaki <ko1@a...>
Date: Sun, 18 Oct 2015 14:46:26 +0900 (JST)
Subject: [ruby-changes:40101] kosaki:r52182 (trunk): Revert r52180

kosaki	2015-10-18 14:46:21 +0900 (Sun, 18 Oct 2015)

  New Revision: 52182

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

  Log:
    Revert r52180

  Modified files:
    trunk/ChangeLog
    trunk/random.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52181)
+++ ChangeLog	(revision 52182)
@@ -3,13 +3,6 @@ Sun Oct 18 14:37:56 2015  KOSAKI Motohir https://github.com/ruby/ruby/blob/trunk/ChangeLog#L3
 	* random.c (fill_random_bytes_urandom): add a comment why using
 	  O_NONBLOCK and O_NOCTTY.
 
-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 52181)
+++ random.c	(revision 52182)
@@ -523,6 +523,10 @@ fill_random_bytes_syscall(void *seed, si https://github.com/ruby/ruby/blob/trunk/random.c#L523
 #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)
 {
@@ -530,7 +534,7 @@ fill_random_bytes_syscall(void *seed, si https://github.com/ruby/ruby/blob/trunk/random.c#L534
     if (try_syscall) {
 	long ret;
 	errno = 0;
-	ret = syscall(SYS_getrandom, seed, size, 0);
+	ret = syscall(SYS_getrandom, seed, size, GRND_NONBLOCK);
 	if (errno == ENOSYS) {
 	    ATOMIC_SET(try_syscall, 0);
 	    return -1;

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

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