shmem_startup_hook
共享内存初始化
此时允许可加载模块设置其共享内存分配。
当前查看 PostgreSQL 18。
中文定义与说明
此时允许可加载模块设置其共享内存分配。
以下中文为本站依据所列 PostgreSQL 源码注释编译的说明。
接口声明
typedef void (*shmem_startup_hook_type) (void); extern PGDLLIMPORT shmem_startup_hook_type shmem_startup_hook;
调用位置
src/backend/storage/ipc/ipci.c:191src/backend/storage/ipc/ipci.c:249
核心调用上下文:src/backend/storage/ipc/ipci.c:185–199
CreateOrAttachShmemStructs(); /* * Now give loadable modules a chance to set up their shmem allocations */ if (shmem_startup_hook) shmem_startup_hook(); } #endif /* * CreateSharedMemoryAndSemaphores * Creates and initializes shared memory and semaphores. */ void
核心调用上下文:src/backend/storage/ipc/ipci.c:243–257
dsm_postmaster_startup(shim); /* * Now give loadable modules a chance to set up their shmem allocations */ if (shmem_startup_hook) shmem_startup_hook(); } /* * Initialize various subsystems, setting up their data structures in * shared memory. * * This is called by the postmaster or by a standalone backend. * It is also called by a backend forked from the postmaster in the
说明
此时允许可加载模块设置其共享内存分配。
- 接口类型
- shmem_startup_hook_type
- 声明头文件
- src/include/storage/ipc.h
- 调用阶段
- 启动与共享内存
- 初始值
- NULL(未安装钩子)
接口签名
typedef void (*shmem_startup_hook_type) (void);
extern PGDLLIMPORT shmem_startup_hook_type shmem_startup_hook;共享状态的并发保护
多个后端连接同一共享结构时必须按该结构的设计使用合适的锁,并检查 ShmemInitStruct 返回的 found 标志,避免把已存在的共享状态重新初始化。
调用位置
src/backend/storage/ipc/ipci.c:191
src/backend/storage/ipc/ipci.c:249
相关条目
文档与源码
查看来源构建
- 版本
- 18
- 构建
- REL_18_STABLE
- 来源指纹
753057e340da8f22e57c9a409ea7a235fd6a46bd
同类条目
shmem_request_hook共享内存需求申报
返回扩展钩子 · 此条目的收录范围为 PostgreSQL 10 至 20;起点不一定是实际引入版本。