git: 2ae65d449fec - main - Revert "Fix race between first rand(3) calls."

Alexander Motin mav at FreeBSD.org
Wed Jul 21 15:32:27 UTC 2021


The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=2ae65d449fecf22f493ce2dcb9e293bb8d95c8ef

commit 2ae65d449fecf22f493ce2dcb9e293bb8d95c8ef
Author:     Alexander Motin <mav at FreeBSD.org>
AuthorDate: 2021-07-21 14:50:14 +0000
Commit:     Alexander Motin <mav at FreeBSD.org>
CommitDate: 2021-07-21 15:32:22 +0000

    Revert "Fix race between first rand(3) calls."
    
    It is going to be reimplemented with _once().
    
    This reverts commit 28d70deaafa62c5d1602de5272c0aad0fcca8aff.
    
    MFC after:      1 month
---
 lib/libc/stdlib/rand.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index 353f59349e1d..bddb0f040302 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
 #include <stdbool.h>
 #include <stdlib.h>
 #include <syslog.h>
-#include <machine/atomic.h>
 #include "un-namespace.h"
 
 #include "random.h"
@@ -69,15 +68,11 @@ static struct __random_state *rand3_state;
 static void
 initialize_rand3(void)
 {
-	struct __random_state *state;
 	int error;
 
-	state = allocatestate(TYPE_3);
-	error = initstate_r(state, 1, state->rst_randtbl, BREAK_3);
+	rand3_state = allocatestate(TYPE_3);
+	error = initstate_r(rand3_state, 1, rand3_state->rst_randtbl, BREAK_3);
 	assert(error == 0);
-	if (!atomic_cmpset_rel_ptr((volatile uintptr_t *)&rand3_state,
-	    (uintptr_t)NULL, (uintptr_t)state))
-		free(state);
 }
 
 int


More information about the dev-commits-src-main mailing list