Mon Sep 25 13:29:53 CEST 2006 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Mon, 25 Sep 2006 11:50:33 +0000 (11:50 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Mon, 25 Sep 2006 11:50:33 +0000 (11:50 -0000)
* rand.c: fix read loop to correctly handle EINTR.

svn path=/trunk/mono/; revision=65881

mono/metadata/ChangeLog
mono/metadata/rand.c

index d9905d8c5e688aa5dfa188af076914abb6150761..6f167ca2220d44bd200842967e28183eeb956980 100644 (file)
@@ -1,4 +1,8 @@
 
+Mon Sep 25 13:29:53 CEST 2006 Paolo Molaro <lupus@ximian.com>
+
+       * rand.c: fix read loop to correctly handle EINTR.
+
 Mon Sep 25 11:33:06 CEST 2006 Paolo Molaro <lupus@ximian.com>
 
        * Makefile.am, icall-def.h, icall.c, verify.c: changed the way
index 6056e13c7391591003554675140319cea44813b6..28e4b8716022d292b3251a7b774e2b5ccbdf43a8 100644 (file)
@@ -229,16 +229,20 @@ ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngGetBytes (gpo
                        return NULL; 
                get_entropy_from_server (socket_path, mono_array_addr (arry, guchar, 0), mono_array_length (arry));
                return (gpointer) -1;
-       }
-       else {
+       } else {
                /* Read until the buffer is filled. This may block if using NAME_DEV_RANDOM. */
                gint count = 0;
                gint err;
 
                do {
                        err = read (file, buf + count, len - count);
+                       if (err < 0) {
+                               if (errno == EINTR)
+                                       continue;
+                               break;
+                       }
                        count += err;
-               } while (err >= 0 && count < len);
+               } while (count < len);
 
                if (err < 0) {
                        g_warning("Entropy error! Error in read (%s).", strerror (errno));