]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
rnd-common: added faster detection of getrandom based on GRND_NONBLOCK
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 15 Jul 2016 16:51:14 +0000 (18:51 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 15 Jul 2016 16:51:14 +0000 (18:51 +0200)
lib/nettle/rnd-common.c

index 5cb9e880429eedb16ac8f7313fa2f0014ce50880..992d1cd3cfcf27d08c2f1ed02a3307b408217b57 100644 (file)
@@ -187,7 +187,9 @@ void _rnd_system_entropy_deinit(void)
 static unsigned have_getrandom(void)
 {
        char c;
-       if (getrandom(&c, 1, 0) == 1)
+       int ret;
+       ret = getrandom(&c, 1, 1/*GRND_NONBLOCK*/);
+       if (ret == 1 || (ret == -1 && errno == EAGAIN))
                return 1;
        return 0;
 }