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

Commitdad75a6

Browse files
committed
Create a "shmem_startup_hook" to be called at the end of shared memory
initialization, to give loadable modules a reasonable place to performcreation of any shared memory areas they need. This is the logical conclusionof our previous creation of RequestAddinShmemSpace() and RequestAddinLWLocks().We don't need an explicit shmem_shutdown_hook, because the existingon_shmem_exit and on_proc_exit mechanisms serve that need.Also, adjust SubPostmasterMain so that libraries that got loaded into thepostmaster will be loaded into all child processes, not only regular backends.This improves consistency with the non-EXEC_BACKEND behavior, and might benecessary for functionality for some types of add-ons.
1 parentbbeb0bb commitdad75a6

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.568 2009/01/01 17:23:46 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.569 2009/01/03 17:08:38 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -3668,6 +3668,14 @@ SubPostmasterMain(int argc, char *argv[])
36683668
/* Read in remaining GUC variables */
36693669
read_nondefault_variables();
36703670

3671+
/*
3672+
* Reload any libraries that were preloaded by the postmaster. Since
3673+
* we exec'd this process, those libraries didn't come along with us;
3674+
* but we should load them into all child processes to be consistent
3675+
* with the non-EXEC_BACKEND behavior.
3676+
*/
3677+
process_shared_preload_libraries();
3678+
36713679
/* Run backend or appropriate child */
36723680
if (strcmp(argv[1],"--forkbackend")==0)
36733681
{
@@ -3680,21 +3688,15 @@ SubPostmasterMain(int argc, char *argv[])
36803688
* Need to reinitialize the SSL library in the backend, since the
36813689
* context structures contain function pointers and cannot be passed
36823690
* through the parameter file.
3691+
*
3692+
* XXX should we do this in all child processes? For the moment it's
3693+
* enough to do it in backend children.
36833694
*/
36843695
#ifdefUSE_SSL
36853696
if (EnableSSL)
36863697
secure_initialize();
36873698
#endif
36883699

3689-
/*
3690-
* process any libraries that should be preloaded at postmaster start
3691-
*
3692-
* NOTE: we have to re-load the shared_preload_libraries here because
3693-
* this backend is not fork()ed so we can't inherit any shared
3694-
* libraries / DLL's from our parent (the postmaster).
3695-
*/
3696-
process_shared_preload_libraries();
3697-
36983700
/*
36993701
* Perform additional initialization and client authentication.
37003702
*

‎src/backend/storage/ipc/ipci.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.98 2009/01/01 17:23:47 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.99 2009/01/03 17:08:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -34,6 +34,8 @@
3434
#include"storage/spin.h"
3535

3636

37+
shmem_startup_hook_typeshmem_startup_hook=NULL;
38+
3739
staticSizetotal_addin_request=0;
3840
staticbooladdin_request_allowed= true;
3941

@@ -222,4 +224,10 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port)
222224
if (!IsUnderPostmaster)
223225
ShmemBackendArrayAllocation();
224226
#endif
227+
228+
/*
229+
* Now give loadable modules a chance to set up their shmem allocations
230+
*/
231+
if (shmem_startup_hook)
232+
shmem_startup_hook();
225233
}

‎src/include/storage/ipc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.76 2009/01/01 17:24:01 momjian Exp $
14+
* $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.77 2009/01/03 17:08:39 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
1818
#ifndefIPC_H
1919
#defineIPC_H
2020

2121
typedefvoid (*pg_on_exit_callback) (intcode,Datumarg);
22+
typedefvoid (*shmem_startup_hook_type) (void);
2223

2324
/*----------
2425
* API for handling cleanup that must occur during either ereport(ERROR)
@@ -71,6 +72,8 @@ extern void cancel_shmem_exit(pg_on_exit_callback function, Datum arg);
7172
externvoidon_exit_reset(void);
7273

7374
/* ipci.c */
75+
externPGDLLIMPORTshmem_startup_hook_typeshmem_startup_hook;
76+
7477
externvoidCreateSharedMemoryAndSemaphores(boolmakePrivate,intport);
7578

7679
#endif/* IPC_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp