Bump version to 47:0
[folly.git] / folly / Random.cpp
index 533ac407a801dc06ea493b1bdfb64b8377d8c7bb..87da68b6b5216469591efd17ad68466fd1c00068 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,9 +31,10 @@ namespace folly {
 namespace {
 
 void readRandomDevice(void* data, size_t size) {
-  // Keep it open for the duration of the program
-  static File randomDevice("/dev/urandom");
-  auto bytesRead = readFull(randomDevice.fd(), data, size);
+  // Keep the random device open for the duration of the program.
+  static int randomFd = ::open("/dev/urandom", O_RDONLY);
+  PCHECK(randomFd >= 0);
+  auto bytesRead = readFull(randomFd, data, size);
   PCHECK(bytesRead >= 0 && size_t(bytesRead) == size);
 }