shithub: riscv

Download patch

ref: a70280308ae782ac422e78ccf19b221697116c1b
parent: a54fcac01609be9438f6fb05b4da4be01c303383
author: cinap_lenrek <[email protected]>
date: Sun Apr 21 09:16:22 EDT 2024

rudp: better newgen() function, avoiding the lock

--- a/sys/src/9/ip/rudp.c
+++ b/sys/src/9/ip/rudp.c
@@ -766,17 +766,12 @@
 static ulong
 newgen(void)
 {
-	static Lock lk;
 	static ulong gen = 0;
-	ulong r;
 
-	lock(&lk);
 	while(gen == 0 || gen == Hangupgen)
 		gen = (nrand(1<<16)<<16)|nrand(1<<16);
-	r = gen++;
-	unlock(&lk);
 
-	return r;
+	return gen++;
 }
 
 /*