Skip to content

Commit 817eabb

Browse files
AaronSchulzKrinkle
authored andcommitted
uuid: Switch mt_rand() calls to random_int() in GlobalIdGenerator
This makes initial clock sequence numbers the strength of the node IDs. Both of which are stored in /tmp files. Change-Id: Ia831baa19a7ba882c3d18196decb7bf3347a4c43
1 parent 16c1648 commit 817eabb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

includes/libs/uuid/GlobalIdGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ protected function getTimeAndDelay( $lockFile, $clockSeqSize, $counterSize, $off
525525
$clkSeq = ( $clkSeq + 1 ) % $clockSeqSize;
526526
$sec = time();
527527
$msecCounter = 0;
528-
$randOffset = mt_rand( 0, $offsetSize - 1 );
528+
$randOffset = random_int( 0, $offsetSize - 1 );
529529
trigger_error( "Clock was set back; sequence number incremented." );
530530
} elseif ( $sec === $prevSec ) {
531531
// The time matches the last ID. Bump the tie-breaking counter.
@@ -541,10 +541,10 @@ protected function getTimeAndDelay( $lockFile, $clockSeqSize, $counterSize, $off
541541
}
542542
} else {
543543
// Initialize UID lock file information
544-
$clkSeq = mt_rand( 0, $clockSeqSize - 1 );
544+
$clkSeq = random_int( 0, $clockSeqSize - 1 );
545545
$sec = time();
546546
$msecCounter = 0;
547-
$randOffset = mt_rand( 0, $offsetSize - 1 );
547+
$randOffset = random_int( 0, $offsetSize - 1 );
548548
}
549549

550550
// Update and release the UID lock file

0 commit comments

Comments
 (0)