|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <signal.h>#include <unistd.h>#include <sys/file.h>#include <sys/ipc.h>#include <sys/mman.h>#include <sys/shm.h>#include <sys/stat.h>#include "miscadmin.h"#include "port/pg_bitutils.h"#include "portability/mem.h"#include "storage/dsm.h"#include "storage/fd.h"#include "storage/ipc.h"#include "storage/pg_shmem.h"#include "utils/guc.h"#include "utils/guc_hooks.h"#include "utils/pidfile.h"
Go to the source code of this file.
Typedefs | |
| typedef key_t | IpcMemoryKey |
| typedef int | IpcMemoryId |
Enumerations | |
| enum | IpcMemoryState { SHMSTATE_ANALYSIS_FAILURE , SHMSTATE_ATTACHED , SHMSTATE_ENOENT , SHMSTATE_FOREIGN , SHMSTATE_UNATTACHED } |
Functions | |
| static void * | InternalIpcMemoryCreate (IpcMemoryKey memKey, Size size) |
| static void | IpcMemoryDetach (int status, Datum shmaddr) |
| static void | IpcMemoryDelete (int status, Datum shmId) |
| static IpcMemoryState | PGSharedMemoryAttach (IpcMemoryId shmId, void *attachAt, PGShmemHeader **addr) |
| bool | PGSharedMemoryIsInUse (unsigned long id1, unsigned long id2) |
| void | GetHugePageSize (Size *hugepagesize, int *mmap_flags) |
| bool | check_huge_page_size (int *newval, void **extra, GucSource source) |
| static void * | CreateAnonymousSegment (Size *size) |
| static void | AnonymousShmemDetach (int status, Datum arg) |
| PGShmemHeader * | PGSharedMemoryCreate (Size size, PGShmemHeader **shim) |
| void | PGSharedMemoryDetach (void) |
Variables | |
| unsigned long | UsedShmemSegID = 0 |
| void * | UsedShmemSegAddr = NULL |
| static Size | AnonymousShmemSize |
| static void * | AnonymousShmem = NULL |
| typedef int IpcMemoryId |
Definition at line 71 of file sysv_shmem.c.
| typedef key_t IpcMemoryKey |
Definition at line 70 of file sysv_shmem.c.
| enum IpcMemoryState |
| Enumerator | |
|---|---|
| SHMSTATE_ANALYSIS_FAILURE | |
| SHMSTATE_ATTACHED | |
| SHMSTATE_ENOENT | |
| SHMSTATE_FOREIGN | |
| SHMSTATE_UNATTACHED | |
Definition at line 84 of file sysv_shmem.c.
|
static |
Definition at line 675 of file sysv_shmem.c.
References AnonymousShmem, AnonymousShmemSize, elog, and LOG.
Referenced by PGSharedMemoryCreate().
| bool check_huge_page_size | ( | int * | newval, |
| void ** | extra, | ||
| GucSource | source | ||
| ) |
Definition at line 578 of file sysv_shmem.c.
References GUC_check_errdetail, and newval.
|
static |
Definition at line 599 of file sysv_shmem.c.
References Assert(), DEBUG1, elog, ereport, errhint(), errmsg(), FATAL, GetHugePageSize(), huge_pages, HUGE_PAGES_ON, HUGE_PAGES_TRY, MAP_FAILED, PG_MMAP_FLAGS, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT, and SetConfigOption().
Referenced by PGSharedMemoryCreate().
| void GetHugePageSize | ( | Size * | hugepagesize, |
| int * | mmap_flags | ||
| ) |
Definition at line 479 of file sysv_shmem.c.
References AllocateFile(), buf, FreeFile(), huge_page_size, and pg_ceil_log2_64().
Referenced by CreateAnonymousSegment(), InitializeShmemGUCs(), and pg_get_shmem_pagesize().
|
static |
Definition at line 121 of file sysv_shmem.c.
References AddToDataDirLockFile(), EIDRM, elog, ereport, errdetail(), errhint(), errmsg(), FATAL, Int32GetDatum(), IPC_CREAT, IPC_EXCL, IPC_RMID, IpcMemoryDelete(), IpcMemoryDetach(), IPCProtection, LOCK_FILE_LINE_SHMEM_KEY, LOG, on_shmem_exit(), PG_SHMAT_FLAGS, PointerGetDatum(), and sprintf.
Referenced by PGSharedMemoryCreate().
|
static |
Definition at line 298 of file sysv_shmem.c.
References DatumGetInt32(), elog, IPC_RMID, and LOG.
Referenced by InternalIpcMemoryCreate().
|
static |
Definition at line 286 of file sysv_shmem.c.
References DatumGetPointer(), elog, and LOG.
Referenced by InternalIpcMemoryCreate().
|
static |
Definition at line 347 of file sysv_shmem.c.
References DataDir, EIDRM, IPC_STAT, PG_SHMAT_FLAGS, PGShmemMagic, SHMSTATE_ANALYSIS_FAILURE, SHMSTATE_ATTACHED, SHMSTATE_ENOENT, SHMSTATE_FOREIGN, SHMSTATE_UNATTACHED, stat::st_dev, stat::st_ino, and stat.
Referenced by PGSharedMemoryCreate(), and PGSharedMemoryIsInUse().
| PGShmemHeader * PGSharedMemoryCreate | ( | Size | size, |
| PGShmemHeader ** | shim | ||
| ) |
Definition at line 700 of file sysv_shmem.c.
References AnonymousShmem, AnonymousShmemDetach(), AnonymousShmemSize, Assert(), CreateAnonymousSegment(), PGShmemHeader::creatorPID, DataDir, PGShmemHeader::device, dsm_cleanup_using_control_segment(), PGShmemHeader::dsm_control, elog, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), ERROR, FATAL, PGShmemHeader::freeoffset, huge_pages, HUGE_PAGES_ON, PGShmemHeader::inode, InternalIpcMemoryCreate(), IPC_RMID, LOG, PGShmemHeader::magic, MAXALIGN, on_shmem_exit(), PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT, PGSharedMemoryAttach(), PGShmemMagic, SetConfigOption(), shared_memory_type, SHMEM_TYPE_MMAP, SHMSTATE_ANALYSIS_FAILURE, SHMSTATE_ATTACHED, SHMSTATE_ENOENT, SHMSTATE_FOREIGN, SHMSTATE_UNATTACHED, stat::st_dev, stat::st_ino, stat, PGShmemHeader::totalsize, UsedShmemSegAddr, and UsedShmemSegID.
Referenced by CreateSharedMemoryAndSemaphores().
| void PGSharedMemoryDetach | ( | void | ) |
Definition at line 970 of file sysv_shmem.c.
References AnonymousShmem, AnonymousShmemSize, elog, LOG, and UsedShmemSegAddr.
Referenced by postmaster_child_launch().
| bool PGSharedMemoryIsInUse | ( | unsigned long | id1, |
| unsigned long | id2 | ||
| ) |
Definition at line 317 of file sysv_shmem.c.
References elog, LOG, PGSharedMemoryAttach(), SHMSTATE_ANALYSIS_FAILURE, SHMSTATE_ATTACHED, SHMSTATE_ENOENT, SHMSTATE_FOREIGN, and SHMSTATE_UNATTACHED.
Referenced by CreateLockFile().
|
static |
Definition at line 98 of file sysv_shmem.c.
Referenced by AnonymousShmemDetach(), PGSharedMemoryCreate(), and PGSharedMemoryDetach().
|
static |
Definition at line 97 of file sysv_shmem.c.
Referenced by AnonymousShmemDetach(), PGSharedMemoryCreate(), and PGSharedMemoryDetach().
| void* UsedShmemSegAddr = NULL |
Definition at line 95 of file sysv_shmem.c.
Referenced by PGSharedMemoryCreate(), and PGSharedMemoryDetach().
| unsigned long UsedShmemSegID = 0 |
Definition at line 94 of file sysv_shmem.c.
Referenced by PGSharedMemoryCreate().