We have in launch_backend.c:
/*
* The following need to be available to the save/restore_backend_variables
* functions. They are marked NON_EXEC_STATIC in their home modules.
*/
extern slock_t *ShmemLock;
extern slock_t *ProcStructLock;
extern PGPROC *AuxiliaryProcs;
extern PMSignalData *PMSignalState;
extern pg_time_t first_syslogger_file_time;
extern struct bkend *ShmemBackendArray;
extern bool redirection_done;
That comment is not completely true: ShmemLock, ShmemBackendArray, and
redirection_done are not in fact NON_EXEC_STATIC. ShmemLock once was,
but was then needed elsewhere. ShmemBackendArray was static inside
postmaster.c before launch_backend.c was created. redirection_done
was never static.
This patch moves the declaration of ShmemLock and redirection_done to
a header file.
ShmemBackendArray gets a NON_EXEC_STATIC. This doesn't make a
difference, since it only exists if EXEC_BACKEND anyway, but it makes
it consistent.
After that, the comment is now correct.
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/
e0a62134-83da-4ba4-8cdb-
ceb0111c95ce@eisentraut.org
index bb1b0ac2b9c9b73330a3f65c7537c16fcb9e3626..49e4be4b399b5c56d17b3fddf7f62cd1053c3e89 100644 (file)
* The following need to be available to the save/restore_backend_variables
* functions. They are marked NON_EXEC_STATIC in their home modules.
*/
-extern slock_t *ShmemLock;
extern slock_t *ProcStructLock;
extern PGPROC *AuxiliaryProcs;
extern PMSignalData *PMSignalState;
extern pg_time_t first_syslogger_file_time;
extern struct bkend *ShmemBackendArray;
-extern bool redirection_done;
#ifndef WIN32
#define write_inheritable_socket(dest, src, childpid) ((*(dest) = (src)), true)
index bf0241aed0cedf9a18edd3625704673b9dfc6ba5..97c8332c84d0339472dce11b3ba6b9470431a1d5 100644 (file)
static dlist_head BackendList = DLIST_STATIC_INIT(BackendList);
#ifdef EXEC_BACKEND
-Backend *ShmemBackendArray;
+NON_EXEC_STATIC Backend *ShmemBackendArray;
#endif
BackgroundWorker *MyBgworkerEntry = NULL;
index 437947dbb9d66d8c29b5e46c4b50596551980123..7951599fa87be440c57dc31b836126ba56cc7e64 100644 (file)
bool Log_truncate_on_rotation = false;
int Log_file_mode = S_IRUSR | S_IWUSR;
-extern bool redirection_done;
-
/*
* Private state
*/
index b1e388dc7c97656ade5affe8adc2ada37e4cdbcb..e765754d80546e0e65db9782f2775b6342cd8abf 100644 (file)
#endif
-/* We use the ShmemLock spinlock to protect LWLockCounter */
-extern slock_t *ShmemLock;
-
#define LW_FLAG_HAS_WAITERS ((uint32) 1 << 30)
#define LW_FLAG_RELEASE_OK ((uint32) 1 << 29)
#define LW_FLAG_LOCKED ((uint32) 1 << 28)
int *LWLockCounter;
LWLockCounter = (int *) ((char *) MainLWLockArray - sizeof(int));
+ /* We use the ShmemLock spinlock to protect LWLockCounter */
SpinLockAcquire(ShmemLock);
result = (*LWLockCounter)++;
SpinLockRelease(ShmemLock);
index d1d1632bdd457ecabc3a728ac7eeb1d66ff92e54..3e42f5754fe633ccd4b03c2adf19389e1dc45984 100644 (file)
@@ -95,8 +95,6 @@ ErrorContextCallback *error_context_stack = NULL;
sigjmp_buf *PG_exception_stack = NULL;
-extern bool redirection_done;
-
/*
* Hook for intercepting messages before they are sent to the server log.
* Note that the hook will not get called for messages that are suppressed
index 89ad13b788b1edc5bb842f5701dbb8e306706249..9feb2e4de14d6645f31574e4512585149cc736b4 100644 (file)
@@ -52,6 +52,7 @@ extern PGDLLIMPORT int postmaster_alive_fds[2];
extern PGDLLIMPORT const char *progname;
+extern PGDLLIMPORT bool redirection_done;
extern PGDLLIMPORT bool LoadedSSL;
extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();
index 3b0cc9d380033c22b9a79e26e16f3b4735cee7ec..842989111c31a5473ebe57083572125ae3dab201 100644 (file)
#ifndef SHMEM_H
#define SHMEM_H
+#include "storage/spin.h"
#include "utils/hsearch.h"
/* shmem.c */
+extern PGDLLIMPORT slock_t *ShmemLock;
extern void InitShmemAccess(void *seghdr);
extern void InitShmemAllocation(void);
extern void *ShmemAlloc(Size size);