Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit470d886

Browse files
committed
Use PostmasterRandom(), not random(), for DSM control segment ID.
Otherwise, every startup gets the same "random" value, which isdefinitely not what was intended.
1 parent419113d commit470d886

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
staticintinitMasks(fd_set*rmask);
404404
staticvoidreport_fork_failure_to_client(Port*port,interrnum);
405405
staticCAC_statecanAcceptConnections(void);
406-
staticlongPostmasterRandom(void);
407406
staticvoidRandomSalt(char*salt,intlen);
408407
staticvoidsignal_child(pid_tpid,intsignal);
409408
staticboolSignalSomeChildren(intsignal,inttargets);
@@ -5101,7 +5100,7 @@ RandomSalt(char *salt, int len)
51015100
/*
51025101
* PostmasterRandom
51035102
*/
5104-
staticlong
5103+
long
51055104
PostmasterRandom(void)
51065105
{
51075106
/*

‎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"
@@ -181,7 +182,7 @@ dsm_postmaster_startup(PGShmemHeader *shim)
181182
{
182183
Assert(dsm_control_address==NULL);
183184
Assert(dsm_control_mapped_size==0);
184-
dsm_control_handle=random();
185+
dsm_control_handle=(dsm_handle)PostmasterRandom();
185186
if (dsm_control_handle==0)
186187
continue;
187188
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
externvoidPostmasterMain(intargc,char*argv[])pg_attribute_noreturn();
5050
externvoidClosePostmasterPorts(boolam_syslogger);
51+
externlongPostmasterRandom(void);
5152

5253
externintMaxLivePostmasterChildren(void);
5354

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp