Chromium Code Reviews| Index: runtime/bin/crypto_macos.cc |
| diff --git a/runtime/bin/crypto_macos.cc b/runtime/bin/crypto_macos.cc |
| index d808d416b608a571c807fa9fcfc6f97ae6396d37..3498636bb0d27af1a729b229f40f06aab9339900 100644 |
| --- a/runtime/bin/crypto_macos.cc |
| +++ b/runtime/bin/crypto_macos.cc |
| @@ -10,7 +10,6 @@ |
| #include "bin/fdutils.h" |
| #include "bin/crypto.h" |
| - |
| #include "platform/signal_blocker.h" |
| @@ -18,11 +17,24 @@ namespace dart { |
| namespace bin { |
| bool Crypto::GetRandomBytes(intptr_t count, uint8_t* buffer) { |
| - intptr_t fd = TEMP_FAILURE_RETRY(open("/dev/urandom", O_RDONLY)); |
| + ThreadSignalBlocker signal_blocker(SIGPROF); |
|
Søren Gjesse
2014/03/25 08:21:23
Maybe there are other places where we can do the s
Anders Johnsen
2014/03/25 13:06:03
Found another use-case in eventhandler :)
|
| + intptr_t fd = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( |
| + open("/dev/urandom", O_RDONLY)); |
| if (fd < 0) return false; |
| - intptr_t bytes_read = FDUtils::ReadFromBlocking(fd, buffer, count); |
| - VOID_TEMP_FAILURE_RETRY(close(fd)); |
| - return bytes_read == count; |
| + intptr_t bytes_read = 0; |
| + do { |
| + int res = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( |
| + read(fd, buffer + bytes_read, count - bytes_read)); |
| + if (res < 0) { |
| + int err = errno; |
| + VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(close(fd)); |
| + errno = err; |
| + return false; |
| + } |
| + bytes_read += res; |
| + } while (bytes_read < count); |
| + VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(close(fd)); |
| + return true; |
| } |
| } // namespace bin |