PostgreSQL解読室:
InternalIpcMemoryCreate()/postgresql-8.1.4
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
このページを編集する際は、[[編集に関する方針]]に従ってく...
*概要 [#k40a073f]
-対象:8.1.4
-言語:C
-宣言・定義:[[postgresql-8.1.4/src/backend/port/sysv_shm...
-(概要を書いてください。)
*引数 [#sdf52378]
-IpcMemoryKey memKey --
-Size size --
*実装 [#f010cb85]
static void *
InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
-[[IpcMemoryKey/postgresql-8.1.4]] -- key_tの別名
-[[Size/postgresql-8.1.4]] -- size_tの別名
{
IpcMemoryId shmid;
-[[IpcMemoryId/postgresql-8.1.4]] -- intの別名
void *memAddress;
shmid = shmget(memKey, size, IPC_CREAT | IPC_EXCL | IPCP...
-shmget(), IPC_CREAT, IPC_EXCL -- sys/ipc.h または sys/sh...
-- &color(red){(shmget()は)}; セマフォ集合の識別子を取得...
--IPC_CREAT が指定されていて、 key &color(red){(memKey)};...
--IPC_CREAT と IPC_EXCL の両方が指定された場合、 key &col...
-[[IPCProtection/postgresql-8.1.4]] -- 定数0600。
if (shmid < 0)
{
/*
* Fail quietly if error indicates a collision with exi...
* One would expect EEXIST, given that we said IPC_EXCL...
* we could get a permission violation instead? Also, ...
* occur if an old seg is slated for destruction but no...
*/
if (errno == EEXIST || errno == EACCES
#ifdef EIDRM
|| errno == EIDRM
-errno, EEXIST, EACCES, EIDRM -- errnoはUNIXで標準的に提...
--EACCES 許可がない (POSIX.1)
--EEXIST ファイルが存在する (POSIX.1)
--EIDRM 識別子が削除された (POSIX.1)
#endif
)
return NULL;
/*
* Else complain and abort
*/
ereport(FATAL,
-[[ereport()/postgresql-8.1.4]]
(errmsg("could not create shared memory segment: %m"),
errdetail("Failed system call was shmget(key=%lu, siz...
(unsigned long) memKey, (unsigned long) size,
IPC_CREAT | IPC_EXCL | IPCProtection),
(errno == EINVAL) ?
errhint("This error usually means that PostgreSQL's ...
"segment exceeded your kernel's SHMMAX parameter. Yo...
"reduce the request size or reconfigure the kernel...
"To reduce the request size (currently %lu bytes), ...
"PostgreSQL's shared_buffers parameter (currently %...
"its max_connections parameter (currently %d).\n"
"If the request size is already small, it's possib...
"your kernel's SHMMIN parameter, in which case rai...
"reconfiguring SHMMIN is called for.\n"
"The PostgreSQL documentation contains more information...
"memory configuration.",
(unsigned long) size, NBuffers, MaxBackends) : 0,
(errno == ENOMEM) ?
errhint("This error usually means that PostgreSQL's ...
"memory segment exceeded available memory or swap ...
"To reduce the request size (currently %lu bytes), ...
"PostgreSQL's shared_buffers parameter (currently %...
"its max_connections parameter (currently %d).\n"
"The PostgreSQL documentation contains more information...
"memory configuration.",
(unsigned long) size, NBuffers, MaxBackends) : 0,
(errno == ENOSPC) ?
errhint("This error does *not* mean that you have ru...
"It occurs either if all available shared memory I...
"in which case you need to raise the SHMMNI parame...
"or because the system's overall limit for shared mem...
"reached. If you cannot increase the shared memory ...
"reduce PostgreSQL's shared memory request (currently...
"by reducing its shared_buffers parameter (currently %...
"its max_connections parameter (currently %d).\n"
"The PostgreSQL documentation contains more information...
"memory configuration.",
(unsigned long) size, NBuffers, MaxBackends) : 0));
}
/* Register on-exit routine to delete the new segment */
on_shmem_exit(IpcMemoryDelete, Int32GetDatum(shmid));
/* OK, should be able to attach to the segment */
memAddress = shmat(shmid, NULL, PG_SHMAT_FLAGS);
if (memAddress == (void *) -1)
elog(FATAL, "shmat(id=%d) failed: %m", shmid);
/* Register on-exit routine to detach new segment before...
on_shmem_exit(IpcMemoryDetach, PointerGetDatum(memAddres...
/* Record key and ID in lockfile for data directory. */
RecordSharedMemoryInLockFile((unsigned long) memKey,
(unsigned long) shmid);
return memAddress;
}
*呼出元 [#t44d5d2a]
-[[PGSharedMemoryCreate()/postgresql-8.1.4]]
*備考 [#m3fc44bf]
/*
* InternalIpcMemoryCreate(memKey, size)
*
* Attempt to create a new shared memory segment with the...
* Will fail (return NULL) if such a segment already exis...
* attach the segment to the current process and return i...
* On success, callbacks are registered with on_shmem_exi...
* delete the segment when on_shmem_exit is called.
*
* If we fail with a failure code other than collision-wi...
* print out an error and abort. Other types of errors a...
*/
*履歴 [#h7a3a129]
-作者:[[/ページ作者]]
-日付:????/?/?
|更新日|更新者|更新内容|
||||
終了行:
このページを編集する際は、[[編集に関する方針]]に従ってく...
*概要 [#k40a073f]
-対象:8.1.4
-言語:C
-宣言・定義:[[postgresql-8.1.4/src/backend/port/sysv_shm...
-(概要を書いてください。)
*引数 [#sdf52378]
-IpcMemoryKey memKey --
-Size size --
*実装 [#f010cb85]
static void *
InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
-[[IpcMemoryKey/postgresql-8.1.4]] -- key_tの別名
-[[Size/postgresql-8.1.4]] -- size_tの別名
{
IpcMemoryId shmid;
-[[IpcMemoryId/postgresql-8.1.4]] -- intの別名
void *memAddress;
shmid = shmget(memKey, size, IPC_CREAT | IPC_EXCL | IPCP...
-shmget(), IPC_CREAT, IPC_EXCL -- sys/ipc.h または sys/sh...
-- &color(red){(shmget()は)}; セマフォ集合の識別子を取得...
--IPC_CREAT が指定されていて、 key &color(red){(memKey)};...
--IPC_CREAT と IPC_EXCL の両方が指定された場合、 key &col...
-[[IPCProtection/postgresql-8.1.4]] -- 定数0600。
if (shmid < 0)
{
/*
* Fail quietly if error indicates a collision with exi...
* One would expect EEXIST, given that we said IPC_EXCL...
* we could get a permission violation instead? Also, ...
* occur if an old seg is slated for destruction but no...
*/
if (errno == EEXIST || errno == EACCES
#ifdef EIDRM
|| errno == EIDRM
-errno, EEXIST, EACCES, EIDRM -- errnoはUNIXで標準的に提...
--EACCES 許可がない (POSIX.1)
--EEXIST ファイルが存在する (POSIX.1)
--EIDRM 識別子が削除された (POSIX.1)
#endif
)
return NULL;
/*
* Else complain and abort
*/
ereport(FATAL,
-[[ereport()/postgresql-8.1.4]]
(errmsg("could not create shared memory segment: %m"),
errdetail("Failed system call was shmget(key=%lu, siz...
(unsigned long) memKey, (unsigned long) size,
IPC_CREAT | IPC_EXCL | IPCProtection),
(errno == EINVAL) ?
errhint("This error usually means that PostgreSQL's ...
"segment exceeded your kernel's SHMMAX parameter. Yo...
"reduce the request size or reconfigure the kernel...
"To reduce the request size (currently %lu bytes), ...
"PostgreSQL's shared_buffers parameter (currently %...
"its max_connections parameter (currently %d).\n"
"If the request size is already small, it's possib...
"your kernel's SHMMIN parameter, in which case rai...
"reconfiguring SHMMIN is called for.\n"
"The PostgreSQL documentation contains more information...
"memory configuration.",
(unsigned long) size, NBuffers, MaxBackends) : 0,
(errno == ENOMEM) ?
errhint("This error usually means that PostgreSQL's ...
"memory segment exceeded available memory or swap ...
"To reduce the request size (currently %lu bytes), ...
"PostgreSQL's shared_buffers parameter (currently %...
"its max_connections parameter (currently %d).\n"
"The PostgreSQL documentation contains more information...
"memory configuration.",
(unsigned long) size, NBuffers, MaxBackends) : 0,
(errno == ENOSPC) ?
errhint("This error does *not* mean that you have ru...
"It occurs either if all available shared memory I...
"in which case you need to raise the SHMMNI parame...
"or because the system's overall limit for shared mem...
"reached. If you cannot increase the shared memory ...
"reduce PostgreSQL's shared memory request (currently...
"by reducing its shared_buffers parameter (currently %...
"its max_connections parameter (currently %d).\n"
"The PostgreSQL documentation contains more information...
"memory configuration.",
(unsigned long) size, NBuffers, MaxBackends) : 0));
}
/* Register on-exit routine to delete the new segment */
on_shmem_exit(IpcMemoryDelete, Int32GetDatum(shmid));
/* OK, should be able to attach to the segment */
memAddress = shmat(shmid, NULL, PG_SHMAT_FLAGS);
if (memAddress == (void *) -1)
elog(FATAL, "shmat(id=%d) failed: %m", shmid);
/* Register on-exit routine to detach new segment before...
on_shmem_exit(IpcMemoryDetach, PointerGetDatum(memAddres...
/* Record key and ID in lockfile for data directory. */
RecordSharedMemoryInLockFile((unsigned long) memKey,
(unsigned long) shmid);
return memAddress;
}
*呼出元 [#t44d5d2a]
-[[PGSharedMemoryCreate()/postgresql-8.1.4]]
*備考 [#m3fc44bf]
/*
* InternalIpcMemoryCreate(memKey, size)
*
* Attempt to create a new shared memory segment with the...
* Will fail (return NULL) if such a segment already exis...
* attach the segment to the current process and return i...
* On success, callbacks are registered with on_shmem_exi...
* delete the segment when on_shmem_exit is called.
*
* If we fail with a failure code other than collision-wi...
* print out an error and abort. Other types of errors a...
*/
*履歴 [#h7a3a129]
-作者:[[/ページ作者]]
-日付:????/?/?
|更新日|更新者|更新内容|
||||
ページ名: