Files
postgresql/src/include/postmaster/postmaster.h
Alvaro Herrera cdbc0ca48c Fix background workers for EXEC_BACKEND
Commit da07a1e8 was broken for EXEC_BACKEND because I failed to realize
that the MaxBackends recomputation needed to be duplicated by
subprocesses in SubPostmasterMain.  However, instead of having the value
be recomputed at all, it's better to assign the correct value at
postmaster initialization time, and have it be propagated to exec'ed
backends via BackendParameters.

MaxBackends stays as zero until after modules in
shared_preload_libraries have had a chance to register bgworkers, since
the value is going to be untrustworthy till that's finished.

Heikki Linnakangas and Álvaro Herrera
2013-01-02 12:01:14 -03:00

74 lines
2.2 KiB
C

/*-------------------------------------------------------------------------
*
* postmaster.h
* Exports from postmaster/postmaster.c.
*
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/postmaster/postmaster.h
*
*-------------------------------------------------------------------------
*/
#ifndef _POSTMASTER_H
#define _POSTMASTER_H
/* GUC options */
extern bool EnableSSL;
extern int ReservedBackends;
extern int PostPortNumber;
extern int Unix_socket_permissions;
extern char *Unix_socket_group;
extern char *Unix_socket_directories;
extern char *ListenAddresses;
extern bool ClientAuthInProgress;
extern int PreAuthDelay;
extern int AuthenticationTimeout;
extern bool Log_connections;
extern bool log_hostname;
extern bool enable_bonjour;
extern char *bonjour_name;
extern bool restart_after_crash;
#ifdef WIN32
extern HANDLE PostmasterHandle;
#else
extern int postmaster_alive_fds[2];
/*
* Constants that represent which of postmaster_alive_fds is held by
* postmaster, and which is used in children to check for postmaster death.
*/
#define POSTMASTER_FD_WATCH 0 /* used in children to check for
* postmaster death */
#define POSTMASTER_FD_OWN 1 /* kept open by postmaster only */
#endif
extern const char *progname;
extern void PostmasterMain(int argc, char *argv[]) __attribute__((noreturn));
extern void ClosePostmasterPorts(bool am_syslogger);
extern int MaxLivePostmasterChildren(void);
extern int GetNumShmemAttachedBgworkers(void);
#ifdef EXEC_BACKEND
extern pid_t postmaster_forkexec(int argc, char *argv[]);
extern void SubPostmasterMain(int argc, char *argv[]) __attribute__((noreturn));
extern Size ShmemBackendArraySize(void);
extern void ShmemBackendArrayAllocation(void);
#endif
/*
* Note: MAX_BACKENDS is limited to 2^23-1 because inval.c stores the
* backend ID as a 3-byte signed integer. Even if that limitation were
* removed, we still could not exceed INT_MAX/4 because some places compute
* 4*MaxBackends without any overflow check. This is rechecked in the relevant
* GUC check hooks and in RegisterBackgroundWorker().
*/
#define MAX_BACKENDS 0x7fffff
#endif /* _POSTMASTER_H */