Skip to content

Commit 52a4581

Browse files
committed
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.
1 parent f629583 commit 52a4581

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.426 2004/10/06 09:35:21 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.427 2004/10/07 00:03:15 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -2575,8 +2575,6 @@ static int
25752575
BackendRun(Port *port)
25762576
{
25772577
int status;
2578-
struct timeval now;
2579-
struct timezone tz;
25802578
char remote_host[NI_MAXHOST];
25812579
char remote_port[NI_MAXSERV];
25822580
char remote_ps_data[NI_MAXHOST];
@@ -2754,9 +2752,7 @@ BackendRun(Port *port)
27542752
* start a new random sequence in the random() library function.
27552753
*/
27562754
random_seed = 0;
2757-
gettimeofday(&now, &tz);
2758-
srandom((unsigned int) now.tv_usec);
2759-
2755+
srandom((unsigned int) (MyProcPid ^ port->session_start.tv_usec));
27602756

27612757
/* ----------------
27622758
* Now, build the argv vector that will be given to PostgresMain.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy