|
10 | 10 | * Portions Copyright (c) 1994, Regents of the University of California
|
11 | 11 | *
|
12 | 12 | * IDENTIFICATION
|
13 |
| - * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.26 2003/11/29 19:51:54 pgsql Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.27 2003/12/01 22:15:37 tgl Exp $ |
14 | 14 | *
|
15 | 15 | *-------------------------------------------------------------------------
|
16 | 16 | */
|
|
34 | 34 | #include "storage/ipc.h"
|
35 | 35 | #include "storage/pg_shmem.h"
|
36 | 36 |
|
| 37 | + |
| 38 | +typedef key_t IpcMemoryKey; /* shared memory key passed to shmget(2) */ |
37 | 39 | typedef int IpcMemoryId; /* shared memory ID returned by shmget(2) */
|
38 | 40 |
|
39 | 41 | #define IPCProtection (0600) /* access/modify by user only */
|
40 | 42 |
|
41 | 43 |
|
42 |
| -IpcMemoryKey UsedShmemSegID = 0; |
| 44 | +unsigned long UsedShmemSegID = 0; |
43 | 45 | void *UsedShmemSegAddr = NULL;
|
44 | 46 |
|
45 | 47 | static void *InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size);
|
@@ -90,8 +92,8 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
|
90 | 92 | */
|
91 | 93 | ereport(FATAL,
|
92 | 94 | (errmsg("could not create shared memory segment: %m"),
|
93 |
| - errdetail("Failed system call was shmget(key=%d, size=%u, 0%o).", |
94 |
| - (int) memKey, size, |
| 95 | + errdetail("Failed system call was shmget(key=%lu, size=%u, 0%o).", |
| 96 | + (unsigned long) memKey, size, |
95 | 97 | IPC_CREAT | IPC_EXCL | IPCProtection),
|
96 | 98 | (errno == EINVAL) ?
|
97 | 99 | errhint("This error usually means that PostgreSQL's request for a shared memory "
|
@@ -247,9 +249,10 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
|
247 | 249 | /* If Exec case, just attach and return the pointer */
|
248 | 250 | if (ExecBackend && UsedShmemSegAddr != NULL && !makePrivate)
|
249 | 251 | {
|
250 |
| - if ((hdr = PGSharedMemoryAttach(UsedShmemSegID, &shmid)) == NULL) |
251 |
| - elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m", |
252 |
| - (int) UsedShmemSegID, UsedShmemSegAddr); |
| 252 | + hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid); |
| 253 | + if (hdr == NULL) |
| 254 | + elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%lu, addr=%p) failed: %m", |
| 255 | + UsedShmemSegID, UsedShmemSegAddr); |
253 | 256 | return hdr;
|
254 | 257 | }
|
255 | 258 |
|
@@ -331,7 +334,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
|
331 | 334 |
|
332 | 335 | /* Save info for possible future use */
|
333 | 336 | UsedShmemSegAddr = memAddress;
|
334 |
| - UsedShmemSegID = NextShmemSegID; |
| 337 | + UsedShmemSegID = (unsigned long) NextShmemSegID; |
335 | 338 |
|
336 | 339 | return hdr;
|
337 | 340 | }
|
|
0 commit comments