Skip to content

Commit 5c2233f

Browse files
committed
runtime: don't use /dev/random on Plan 9
Plan 9 provides a /dev/random device to return a stream of random numbers. However, the method used to generate random numbers on Plan 9 is slow and reading from /dev/random may block. We don't want our Go programs to be significantly slowed down just to slightly improve the distribution of hash values. So, we do the same thing as NaCl and rely exclusively on extendRandom to generate pseudo-random numbers. Fixes golang#10028. Change-Id: I7e11a9b109c22f23608eb09c406b7c3dba31f26a Reviewed-on: https://go-review.googlesource.com/6386 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent f0bd95b commit 5c2233f

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/runtime/os1_plan9.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,9 @@ func crash() {
8585
*(*int)(nil) = 0
8686
}
8787

88-
var random_dev = []byte("/dev/random\x00")
89-
9088
//go:nosplit
9189
func getRandomData(r []byte) {
92-
fd := open(&random_dev[0], 0 /* O_RDONLY */, 0)
93-
n := read(fd, unsafe.Pointer(&r[0]), int32(len(r)))
94-
close(fd)
95-
extendRandom(r, int(n))
90+
extendRandom(r, 0)
9691
}
9792

9893
func goenvs() {

0 commit comments

Comments
 (0)