summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-18 05:42:37 (GMT)
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-18 05:42:37 (GMT)
commit47f0a8f9d04cf1434a22dbfce04b05f1f546468f (patch)
tree9047c01efaecc39bf6c55bc71a9e446b6f3f6940
parenta4c6ad1d1978f1b6007fbe5b0cc5b1abaee67d1a (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--random.c6
2 files changed, 8 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 931ed41..799d586 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Oct 18 13:30:56 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * 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@gmail.com>
* random.c (fill_random_bytes_syscall): use ATOMIC_SET() for
diff --git a/random.c b/random.c
index 4a9d4de..3fcc424 100644
--- a/random.c
+++ b/random.c
@@ -518,10 +518,6 @@ fill_random_bytes_syscall(void *seed, size_t size)
#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, size_t size)
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;