summaryrefslogtreecommitdiff
path: root/src/backend/postmaster/postmaster.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/postmaster/postmaster.c')
-rw-r--r--src/backend/postmaster/postmaster.c62
1 files changed, 1 insertions, 61 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 2d5a0ac7d3b..406cc2cf2d4 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -367,16 +367,6 @@ static volatile sig_atomic_t WalReceiverRequested = false;
static volatile bool StartWorkerNeeded = true;
static volatile bool HaveCrashedWorker = false;
-#ifndef HAVE_STRONG_RANDOM
-/*
- * State for assigning cancel keys.
- * Also, the global MyCancelKey passes the cancel key assigned to a given
- * backend from the postmaster to that backend (via fork).
- */
-static unsigned int random_seed = 0;
-static struct timeval random_start_time;
-#endif
-
#ifdef USE_SSL
/* Set when and if SSL has been initialized properly */
static bool LoadedSSL = false;
@@ -1361,10 +1351,6 @@ PostmasterMain(int argc, char *argv[])
* Remember postmaster startup time
*/
PgStartTime = GetCurrentTimestamp();
-#ifndef HAVE_STRONG_RANDOM
- /* RandomCancelKey wants its own copy */
- gettimeofday(&random_start_time, NULL);
-#endif
/*
* Report postmaster status in the postmaster.pid file, to allow pg_ctl to
@@ -2532,26 +2518,11 @@ InitProcessGlobals(void)
MyStartTime = timestamptz_to_time_t(MyStartTimestamp);
/*
- * Don't want backend to be able to see the postmaster random number
- * generator state. We have to clobber the static random_seed.
- */
-#ifndef HAVE_STRONG_RANDOM
- random_seed = 0;
- random_start_time.tv_usec = 0;
-#endif
-
- /*
* Set a different seed for random() in every process. We want something
* unpredictable, so if possible, use high-quality random bits for the
* seed. Otherwise, fall back to a seed based on timestamp and PID.
- *
- * Note we can't use pg_backend_random here, since this is used in the
- * postmaster, and even in a backend we might not be attached to shared
- * memory yet.
*/
-#ifdef HAVE_STRONG_RANDOM
if (!pg_strong_random(&rseed, sizeof(rseed)))
-#endif
{
/*
* Since PIDs and timestamps tend to change more frequently in their
@@ -5256,38 +5227,7 @@ StartupPacketTimeoutHandler(void)
static bool
RandomCancelKey(int32 *cancel_key)
{
-#ifdef HAVE_STRONG_RANDOM
- return pg_strong_random((char *) cancel_key, sizeof(int32));
-#else
-
- /*
- * If built with --disable-strong-random, use plain old erand48.
- *
- * We cannot use pg_backend_random() in postmaster, because it stores its
- * state in shared memory.
- */
- static unsigned short seed[3];
-
- /*
- * Select a random seed at the time of first receiving a request.
- */
- if (random_seed == 0)
- {
- struct timeval random_stop_time;
-
- gettimeofday(&random_stop_time, NULL);
-
- seed[0] = (unsigned short) random_start_time.tv_usec;
- seed[1] = (unsigned short) (random_stop_time.tv_usec) ^ (random_start_time.tv_usec >> 16);
- seed[2] = (unsigned short) (random_stop_time.tv_usec >> 16);
-
- random_seed = 1;
- }
-
- *cancel_key = pg_jrand48(seed);
-
- return true;
-#endif
+ return pg_strong_random(cancel_key, sizeof(int32));
}
/*