Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
556e603b
Commit
556e603b
authored
Jun 08, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add real random() call to postmaster for use in cancel.
parent
b952a849
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
13 deletions
+41
-13
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+41
-13
No files found.
src/backend/postmaster/postmaster.c
View file @
556e603b
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.8
0 1998/06/04 17:26:41
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.8
1 1998/06/08 04:27:59
momjian Exp $
*
* NOTES
*
...
...
@@ -198,6 +198,12 @@ static sigset_t oldsigmask,
static
int
orgsigmask
=
sigblock
(
0
);
#endif
static
unsigned
int
random_seed
=
0
;
extern
char
*
optarg
;
extern
int
optind
,
opterr
;
/*
* postmaster.c - function prototypes
...
...
@@ -216,18 +222,14 @@ static int ServerLoop(void);
static
int
BackendStartup
(
Port
*
port
);
static
void
readStartupPacket
(
char
*
arg
,
PacketLen
len
,
char
*
pkt
);
static
int
initMasks
(
fd_set
*
rmask
,
fd_set
*
wmask
);
static
long
PostmasterRandom
(
void
);
static
void
RandomSalt
(
char
*
salt
);
#ifdef CYR_RECODE
void
GetCharSetByHost
(
char
*
,
int
,
char
*
);
void
GetCharSetByHost
(
char
*
,
int
,
char
*
);
#endif
extern
char
*
optarg
;
extern
int
optind
,
opterr
;
static
void
checkDataDir
(
const
char
*
DataDir
,
bool
*
DataDirOK
)
...
...
@@ -563,6 +565,10 @@ ServerLoop(void)
writemask
;
int
nSockets
;
Dlelem
*
curr
;
struct
timeval
now
,
later
;
struct
timezone
tz
;
gettimeofday
(
&
now
,
&
tz
);
nSockets
=
initMasks
(
&
readmask
,
&
writemask
);
...
...
@@ -596,6 +602,19 @@ ServerLoop(void)
return
(
STATUS_ERROR
);
}
if
(
random_seed
==
0
)
{
gettimeofday
(
&
later
,
&
tz
);
/*
* We are not sure how much precision is in tv_usec, so we
* swap the nibbles of 'later' and XOR them with 'now'
*/
random_seed
=
now
.
tv_usec
^
((
later
.
tv_usec
<<
16
)
|
((
unsigned
int
)(
later
.
tv_usec
&
0xffff0000
)
>>
16
));
}
/*
* [TRH] To avoid race conditions, block SIGCHLD signals while we
* are handling the request. (both reaper() and ConnCreate()
...
...
@@ -1345,19 +1364,28 @@ CharRemap(long int ch)
*/
static
void
RandomSalt
(
char
*
salt
)
{
long
rand
=
PostmasterRandom
();
*
salt
=
CharRemap
(
rand
%
62
);
*
(
salt
+
1
)
=
CharRemap
(
rand
/
62
);
}
/*
* PostmasterRandom
*/
static
long
PostmasterRandom
(
void
)
{
static
bool
initialized
=
false
;
if
(
!
initialized
)
{
time_t
now
;
now
=
time
(
NULL
);
srandom
((
unsigned
int
)
now
);
Assert
(
random_seed
!=
0
&&
!
IsUnderPostmaster
);
srandom
(
random_seed
);
initialized
=
true
;
}
*
salt
=
CharRemap
(
random
());
*
(
salt
+
1
)
=
CharRemap
(
random
());
return
ramdom
()
^
random_seed
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment