Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 92668cd

Browse files
committed
Use PostmasterRandom(), not random(), for DSM control segment ID.
Otherwise, every startup gets the same "random" value, which is definitely not what was intended.
1 parent 6bcd26c commit 92668cd

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ static void processCancelRequest(Port *port, void *pkt);
403403
static int initMasks(fd_set *rmask);
404404
static void report_fork_failure_to_client(Port *port, int errnum);
405405
static CAC_state canAcceptConnections(void);
406-
static long PostmasterRandom(void);
407406
static void RandomSalt(char *md5Salt);
408407
static void signal_child(pid_t pid, int signal);
409408
static bool SignalSomeChildren(int signal, int targets);
@@ -5103,7 +5102,7 @@ RandomSalt(char *md5Salt)
51035102
/*
51045103
* PostmasterRandom
51055104
*/
5106-
static long
5105+
long
51075106
PostmasterRandom(void)
51085107
{
51095108
/*

src/backend/storage/ipc/dsm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "lib/ilist.h"
3838
#include "miscadmin.h"
39+
#include "postmaster/postmaster.h"
3940
#include "storage/dsm.h"
4041
#include "storage/ipc.h"
4142
#include "storage/lwlock.h"
@@ -179,7 +180,7 @@ dsm_postmaster_startup(PGShmemHeader *shim)
179180
{
180181
Assert(dsm_control_address == NULL);
181182
Assert(dsm_control_mapped_size == 0);
182-
dsm_control_handle = random();
183+
dsm_control_handle = (dsm_handle) PostmasterRandom();
183184
if (dsm_control_handle == 0)
184185
continue;
185186
if (dsm_impl_op(DSM_OP_CREATE, dsm_control_handle, segsize,

src/include/postmaster/postmaster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern const char *progname;
4848

4949
extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();
5050
extern void ClosePostmasterPorts(bool am_syslogger);
51+
extern long PostmasterRandom(void);
5152

5253
extern int MaxLivePostmasterChildren(void);
5354

0 commit comments

Comments
 (0)