diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-04-18 13:19:52 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-04-18 13:19:52 -0400 |
commit | 37f30b2510525155f4f1f94288a015163689cc69 (patch) | |
tree | fc623aace68895adc020cefcc8c0ebc2025d2f2d /src/backend/storage/ipc/shmem.c | |
parent | 9008922bf727ba4337ed26b5c07df7f1d5f1548b (diff) | |
download | postgresql-37f30b2510525155f4f1f94288a015163689cc69.tar.gz postgresql-37f30b2510525155f4f1f94288a015163689cc69.zip |
Fix --disable-spinlocks in 9.2 and 9.3 branches.
My back-patch of the 9.4-era commit 44cd47c1d49655c5 into 9.2 and 9.3 fixed
HPPA builds as expected, but it broke --disable-spinlocks builds, because
the dummy spinlock is initialized before the underlying semaphore
infrastructure is alive. In 9.4 and up this works because of commit
daa7527afc227443, which decoupled initialization of an slock_t variable
from access to the actual system semaphore object. The best solution
seems to be to back-port that patch, which should be a net win anyway
because it improves the usability of --disable-spinlocks builds in the
older branches; and it's been out long enough now to not be worrisome
from a stability perspective.
Diffstat (limited to 'src/backend/storage/ipc/shmem.c')
-rw-r--r-- | src/backend/storage/ipc/shmem.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 5868405d063..aa23162bc7f 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -116,9 +116,24 @@ InitShmemAllocation(void) Assert(shmhdr != NULL); /* - * Initialize the spinlock used by ShmemAlloc. We have to do the space - * allocation the hard way, since obviously ShmemAlloc can't be called - * yet. + * If spinlocks are disabled, initialize emulation layer. We have to do + * the space allocation the hard way, since obviously ShmemAlloc can't be + * called yet. + */ +#ifndef HAVE_SPINLOCKS + { + PGSemaphore spinsemas; + + spinsemas = (PGSemaphore) (((char *) shmhdr) + shmhdr->freeoffset); + shmhdr->freeoffset += MAXALIGN(SpinlockSemaSize()); + SpinlockSemaInit(spinsemas); + Assert(shmhdr->freeoffset <= shmhdr->totalsize); + } +#endif + + /* + * Initialize the spinlock used by ShmemAlloc; we have to do this the hard + * way, too, for the same reasons as above. */ ShmemLock = (slock_t *) (((char *) shmhdr) + shmhdr->freeoffset); shmhdr->freeoffset += MAXALIGN(sizeof(slock_t)); |