Skip to content

Commit 42e2ce6

Browse files
committed
Fix confusion between "size" and "AnonymousShmemSize".
Noted by Andres Freund. Also improve a couple of comments.
1 parent 7a5c9ca commit 42e2ce6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/backend/port/sysv_shmem.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,14 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
408408
long pagesize = sysconf(_SC_PAGE_SIZE);
409409

410410
/*
411+
* Ensure request size is a multiple of pagesize.
412+
*
411413
* pagesize will, for practical purposes, always be a power of two.
412414
* But just in case it isn't, we do it this way instead of using
413415
* TYPEALIGN().
414416
*/
415-
AnonymousShmemSize = size;
416-
if (size % pagesize != 0)
417-
AnonymousShmemSize += pagesize - (size % pagesize);
417+
if (pagesize > 0 && size % pagesize != 0)
418+
size += pagesize - (size % pagesize);
418419

419420
/*
420421
* 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)
435436
"%lu bytes), reduce PostgreSQL's shared memory usage, "
436437
"perhaps by reducing shared_buffers or "
437438
"max_connections.",
438-
(unsigned long) AnonymousShmemSize) : 0));
439+
(unsigned long) size) : 0));
440+
AnonymousShmemSize = size;
439441

440-
/* Now we can allocate a minimal SHM block. */
442+
/* Now we need only allocate a minimal-sized SysV shmem block. */
441443
allocsize = sizeof(PGShmemHeader);
442444
}
443445
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy