Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8f8bcb8

Browse files
committed
Improve some global variable declarations
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
1 parent 881455e commit 8f8bcb8

File tree

7 files changed

+5
-10
lines changed

7 files changed

+5
-10
lines changed

src/backend/postmaster/launch_backend.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,11 @@ SubPostmasterMain(int argc, char *argv[])
672672
* The following need to be available to the save/restore_backend_variables
673673
* functions. They are marked NON_EXEC_STATIC in their home modules.
674674
*/
675-
extern slock_t *ShmemLock;
676675
extern slock_t *ProcStructLock;
677676
extern PGPROC *AuxiliaryProcs;
678677
extern PMSignalData *PMSignalState;
679678
extern pg_time_t first_syslogger_file_time;
680679
extern struct bkend *ShmemBackendArray;
681-
extern bool redirection_done;
682680

683681
#ifndef WIN32
684682
#define write_inheritable_socket(dest, src, childpid) ((*(dest) = (src)), true)

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ typedef struct bkend
179179
static dlist_head BackendList = DLIST_STATIC_INIT(BackendList);
180180

181181
#ifdef EXEC_BACKEND
182-
Backend *ShmemBackendArray;
182+
NON_EXEC_STATIC Backend *ShmemBackendArray;
183183
#endif
184184

185185
BackgroundWorker *MyBgworkerEntry = NULL;

src/backend/postmaster/syslogger.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ char *Log_filename = NULL;
7575
bool Log_truncate_on_rotation = false;
7676
int Log_file_mode = S_IRUSR | S_IWUSR;
7777

78-
extern bool redirection_done;
79-
8078
/*
8179
* Private state
8280
*/

src/backend/storage/lmgr/lwlock.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@
9191
#endif
9292

9393

94-
/* We use the ShmemLock spinlock to protect LWLockCounter */
95-
extern slock_t *ShmemLock;
96-
9794
#define LW_FLAG_HAS_WAITERS ((uint32) 1 << 30)
9895
#define LW_FLAG_RELEASE_OK ((uint32) 1 << 29)
9996
#define LW_FLAG_LOCKED ((uint32) 1 << 28)
@@ -609,6 +606,7 @@ LWLockNewTrancheId(void)
609606
int *LWLockCounter;
610607

611608
LWLockCounter = (int *) ((char *) MainLWLockArray - sizeof(int));
609+
/* We use the ShmemLock spinlock to protect LWLockCounter */
612610
SpinLockAcquire(ShmemLock);
613611
result = (*LWLockCounter)++;
614612
SpinLockRelease(ShmemLock);

src/backend/utils/error/elog.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ ErrorContextCallback *error_context_stack = NULL;
9595

9696
sigjmp_buf *PG_exception_stack = NULL;
9797

98-
extern bool redirection_done;
99-
10098
/*
10199
* Hook for intercepting messages before they are sent to the server log.
102100
* Note that the hook will not get called for messages that are suppressed

src/include/postmaster/postmaster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extern PGDLLIMPORT int postmaster_alive_fds[2];
5252

5353
extern PGDLLIMPORT const char *progname;
5454

55+
extern PGDLLIMPORT bool redirection_done;
5556
extern PGDLLIMPORT bool LoadedSSL;
5657

5758
extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();

src/include/storage/shmem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
#ifndef SHMEM_H
2222
#define SHMEM_H
2323

24+
#include "storage/spin.h"
2425
#include "utils/hsearch.h"
2526

2627

2728
/* shmem.c */
29+
extern PGDLLIMPORT slock_t *ShmemLock;
2830
extern void InitShmemAccess(void *seghdr);
2931
extern void InitShmemAllocation(void);
3032
extern void *ShmemAlloc(Size size);

0 commit comments

Comments
 (0)