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
d9fd7d12
Commit
d9fd7d12
authored
May 06, 2003
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass shared memory id and socket descriptor number on command line for
fork/exec.
parent
e8f4f2f9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
21 deletions
+83
-21
src/backend/bootstrap/bootstrap.c
src/backend/bootstrap/bootstrap.c
+21
-7
src/backend/port/sysv_shmem.c
src/backend/port/sysv_shmem.c
+17
-6
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+22
-2
src/backend/storage/ipc/shmem.c
src/backend/storage/ipc/shmem.c
+2
-3
src/backend/tcop/postgres.c
src/backend/tcop/postgres.c
+14
-2
src/include/storage/pg_shmem.h
src/include/storage/pg_shmem.h
+7
-1
No files found.
src/backend/bootstrap/bootstrap.c
View file @
d9fd7d12
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.15
4 2003/05/06 05:15:4
5 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.15
5 2003/05/06 23:34:5
5 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -36,6 +36,7 @@
#include "miscadmin.h"
#include "storage/freespace.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
#include "storage/proc.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
...
...
@@ -252,7 +253,7 @@ BootstrapMain(int argc, char *argv[])
* variable */
}
while
((
flag
=
getopt
(
argc
,
argv
,
"B:d:D:Fo:px:"
))
!=
-
1
)
while
((
flag
=
getopt
(
argc
,
argv
,
"B:d:D:Fo:p
:
x:"
))
!=
-
1
)
{
switch
(
flag
)
{
...
...
@@ -283,8 +284,19 @@ BootstrapMain(int argc, char *argv[])
xlogop
=
atoi
(
optarg
);
break
;
case
'p'
:
{
/* indicates fork from postmaster */
char
*
p
;
#ifdef EXEC_BACKEND
sscanf
(
optarg
,
"%d,"
,
&
UsedShmemSegID
);
p
=
strchr
(
optarg
,
','
);
if
(
p
)
dbname
=
strdup
(
p
+
1
);
#else
dbname
=
strdup
(
optarg
);
#endif
break
;
}
case
'B'
:
SetConfigOption
(
"shared_buffers"
,
optarg
,
PGC_POSTMASTER
,
PGC_S_ARGV
);
break
;
...
...
@@ -292,14 +304,16 @@ BootstrapMain(int argc, char *argv[])
usage
();
break
;
}
}
/* while */
}
if
(
argc
-
optind
!=
1
)
if
(
!
dbname
&&
argc
-
optind
==
1
)
{
dbname
=
argv
[
optind
];
optind
++
;
}
if
(
!
dbname
||
argc
!=
optind
)
usage
();
dbname
=
argv
[
optind
];
Assert
(
dbname
);
if
(
IsUnderPostmaster
&&
ExecBackend
&&
MyProc
/* ordinary backend */
)
{
...
...
src/backend/port/sysv_shmem.c
View file @
d9fd7d12
...
...
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.
7 2003/04/24 21:24:36
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.
8 2003/05/06 23:34:55
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -34,13 +34,15 @@
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
typedef
uint32
IpcMemoryKey
;
/* shared memory key passed to shmget(2) */
typedef
int
IpcMemoryId
;
/* shared memory ID returned by shmget(2) */
#define IPCProtection (0600)
/* access/modify by user only */
#ifdef EXEC_BACKEND
IpcMemoryKey
UsedShmemSegID
=
0
;
#endif
static
void
*
InternalIpcMemoryCreate
(
IpcMemoryKey
memKey
,
uint32
size
);
static
void
IpcMemoryDetach
(
int
status
,
Datum
shmaddr
);
static
void
IpcMemoryDelete
(
int
status
,
Datum
shmId
);
...
...
@@ -300,10 +302,14 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
/* Room for a header? */
Assert
(
size
>
MAXALIGN
(
sizeof
(
PGShmemHeader
)));
/* Loop till we find a free IPC key */
NextShmemSegID
=
port
*
1000
;
#ifdef EXEC_BACKEND
if
(
UsedShmemSegID
!=
0
)
NextShmemSegID
=
UsedShmemSegID
;
else
#endif
NextShmemSegID
=
port
*
1000
+
1
;
for
(
NextShmemSegID
++
;;
NextShmemSegID
++
)
for
(
;;
NextShmemSegID
++
)
{
IpcMemoryId
shmid
;
...
...
@@ -395,5 +401,10 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
hdr
->
totalsize
=
size
;
hdr
->
freeoffset
=
MAXALIGN
(
sizeof
(
PGShmemHeader
));
#ifdef EXEC_BACKEND
if
(
!
makePrivate
&&
UsedShmemSegID
==
0
)
UsedShmemSegID
=
NextShmemSegID
;
#endif
return
hdr
;
}
src/backend/postmaster/postmaster.c
View file @
d9fd7d12
...
...
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.32
1 2003/05/03 05:13:18
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.32
2 2003/05/06 23:34:55
momjian Exp $
*
* NOTES
*
...
...
@@ -97,6 +97,7 @@
#include "nodes/nodes.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "access/xlog.h"
...
...
@@ -2214,6 +2215,9 @@ BackendFinalize(Port *port)
int
ac
;
char
debugbuf
[
32
];
char
protobuf
[
32
];
#ifdef EXEC_BACKEND
char
pbuf
[
NAMEDATALEN
+
256
];
#endif
int
i
;
int
status
;
struct
timeval
now
;
...
...
@@ -2434,8 +2438,14 @@ BackendFinalize(Port *port)
* database to use. -p marks the end of secure switches.
*/
av
[
ac
++
]
=
"-p"
;
#ifdef EXEC_BACKEND
Assert
(
UsedShmemSegID
!=
0
);
/* database name at the end because it might contain commas */
snprintf
(
pbuf
,
NAMEDATALEN
+
256
,
"%d,%d,%s"
,
port
->
sock
,
UsedShmemSegID
,
port
->
database_name
);
av
[
ac
++
]
=
pbuf
;
#else
av
[
ac
++
]
=
port
->
database_name
;
#endif
/*
* Pass the (insecure) option switches from the connection request.
* (It's OK to mangle port->cmdline_options now.)
...
...
@@ -2712,6 +2722,9 @@ SSDataBase(int xlop)
int
ac
=
0
;
char
nbbuf
[
32
];
char
xlbuf
[
32
];
#ifdef EXEC_BACKEND
char
pbuf
[
NAMEDATALEN
+
256
];
#endif
#ifdef LINUX_PROFILE
setitimer
(
ITIMER_PROF
,
&
prof_itimer
,
NULL
);
...
...
@@ -2762,7 +2775,14 @@ SSDataBase(int xlop)
av
[
ac
++
]
=
xlbuf
;
av
[
ac
++
]
=
"-p"
;
#ifdef EXEC_BACKEND
Assert
(
UsedShmemSegID
!=
0
);
/* database name at the end because it might contain commas */
snprintf
(
pbuf
,
NAMEDATALEN
+
256
,
"%d,%s"
,
UsedShmemSegID
,
"template1"
);
av
[
ac
++
]
=
pbuf
;
#else
av
[
ac
++
]
=
"template1"
;
#endif
av
[
ac
]
=
(
char
*
)
NULL
;
...
...
src/backend/storage/ipc/shmem.c
View file @
d9fd7d12
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.6
7 2002/09/04 20:31:2
5 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.6
8 2003/05/06 23:34:5
5 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -365,8 +365,7 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
hash_search
(
ShmemIndex
,
(
void
*
)
&
item
,
HASH_REMOVE
,
NULL
);
LWLockRelease
(
ShmemIndexLock
);
elog
(
WARNING
,
"ShmemInitStruct: cannot allocate '%s'"
,
name
);
elog
(
WARNING
,
"ShmemInitStruct: cannot allocate '%s'"
,
name
);
*
foundPtr
=
FALSE
;
return
NULL
;
}
...
...
src/backend/tcop/postgres.c
View file @
d9fd7d12
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.33
7 2003/05/06 21:51:41 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.33
8 2003/05/06 23:34:55 momjian
Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
...
...
@@ -51,6 +51,7 @@
#include "rewrite/rewriteHandler.h"
#include "storage/freespace.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
#include "storage/proc.h"
#include "tcop/fastpath.h"
#include "tcop/pquery.h"
...
...
@@ -2024,7 +2025,18 @@ PostgresMain(int argc, char *argv[], const char *username)
*/
if
(
secure
)
{
char
*
p
;
#ifdef EXEC_BACKEND
sscanf
(
optarg
,
"%d,%d,"
,
&
MyProcPort
->
sock
,
&
UsedShmemSegID
);
/* Grab dbname as last param */
p
=
strchr
(
optarg
,
','
);
if
(
p
)
p
=
strchr
(
p
+
1
,
','
);
if
(
p
)
dbname
=
strdup
(
p
+
1
);
#else
dbname
=
strdup
(
optarg
);
#endif
secure
=
false
;
/* subsequent switches are NOT
* secure */
ctx
=
PGC_BACKEND
;
...
...
@@ -2381,7 +2393,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if
(
!
IsUnderPostmaster
)
{
puts
(
"
\n
POSTGRES backend interactive interface "
);
puts
(
"$Revision: 1.33
7 $ $Date: 2003/05/06 21:51:41
$
\n
"
);
puts
(
"$Revision: 1.33
8 $ $Date: 2003/05/06 23:34:55
$
\n
"
);
}
/*
...
...
src/include/storage/pg_shmem.h
View file @
d9fd7d12
...
...
@@ -17,13 +17,15 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_shmem.h,v 1.
4 2002/09/04 20:31:45
momjian Exp $
* $Id: pg_shmem.h,v 1.
5 2003/05/06 23:34:56
momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PG_SHMEM_H
#define PG_SHMEM_H
typedef
uint32
IpcMemoryKey
;
/* shared memory key passed to shmget(2) */
typedef
struct
PGShmemHeader
/* standard header for all Postgres shmem */
{
int32
magic
;
/* magic # to identify Postgres segments */
...
...
@@ -34,6 +36,10 @@ typedef struct PGShmemHeader /* standard header for all Postgres shmem */
}
PGShmemHeader
;
#ifdef EXEC_BACKEND
extern
IpcMemoryKey
UsedShmemSegID
;
#endif
extern
PGShmemHeader
*
PGSharedMemoryCreate
(
uint32
size
,
bool
makePrivate
,
int
port
);
extern
bool
PGSharedMemoryIsInUse
(
unsigned
long
id1
,
unsigned
long
id2
);
...
...
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