diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-06-29 15:12:10 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-06-29 15:12:10 -0400 |
| commit | 42e2ce6ae3e931953135a55b173a5ec4c54506c4 (patch) | |
| tree | 0dfccf818f203c6ed7746d78f1aa1d93830edd7e /src | |
| parent | 7a5c9ca93ad7d9b84f612d6157bf8990c7041d3c (diff) | |
| download | postgresql-42e2ce6ae3e931953135a55b173a5ec4c54506c4.tar.gz | |
Fix confusion between "size" and "AnonymousShmemSize".
Noted by Andres Freund. Also improve a couple of comments.
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/port/sysv_shmem.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 8f1da7a7ef..e040400bb1 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -408,13 +408,14 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) long pagesize = sysconf(_SC_PAGE_SIZE); /* + * Ensure request size is a multiple of pagesize. + * * pagesize will, for practical purposes, always be a power of two. * But just in case it isn't, we do it this way instead of using * TYPEALIGN(). */ - AnonymousShmemSize = size; - if (size % pagesize != 0) - AnonymousShmemSize += pagesize - (size % pagesize); + if (pagesize > 0 && size % pagesize != 0) + size += pagesize - (size % pagesize); /* * We assume that no one will attempt to run PostgreSQL 9.3 or later @@ -435,9 +436,10 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) "%lu bytes), reduce PostgreSQL's shared memory usage, " "perhaps by reducing shared_buffers or " "max_connections.", - (unsigned long) AnonymousShmemSize) : 0)); + (unsigned long) size) : 0)); + AnonymousShmemSize = size; - /* Now we can allocate a minimal SHM block. */ + /* Now we need only allocate a minimal-sized SysV shmem block. */ allocsize = sizeof(PGShmemHeader); } #endif |
