mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
XOR process PID into a backend's initial random seed, to ensure that
different backends get a reasonably wide set of initial seeds even if gettimeofday returns tv_usec values with only a few bits of precision. Per recent discussion.
This commit is contained in:
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.426 2004/10/06 09:35:21 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.427 2004/10/07 00:03:15 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -2575,8 +2575,6 @@ static int
|
|||||||
BackendRun(Port *port)
|
BackendRun(Port *port)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
struct timeval now;
|
|
||||||
struct timezone tz;
|
|
||||||
char remote_host[NI_MAXHOST];
|
char remote_host[NI_MAXHOST];
|
||||||
char remote_port[NI_MAXSERV];
|
char remote_port[NI_MAXSERV];
|
||||||
char remote_ps_data[NI_MAXHOST];
|
char remote_ps_data[NI_MAXHOST];
|
||||||
@ -2754,9 +2752,7 @@ BackendRun(Port *port)
|
|||||||
* start a new random sequence in the random() library function.
|
* start a new random sequence in the random() library function.
|
||||||
*/
|
*/
|
||||||
random_seed = 0;
|
random_seed = 0;
|
||||||
gettimeofday(&now, &tz);
|
srandom((unsigned int) (MyProcPid ^ port->session_start.tv_usec));
|
||||||
srandom((unsigned int) now.tv_usec);
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Now, build the argv vector that will be given to PostgresMain.
|
* Now, build the argv vector that will be given to PostgresMain.
|
||||||
|
Reference in New Issue
Block a user