]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add code to InternalIpcMemoryCreate() to handle the case where shmget()
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 1 May 2010 22:47:00 +0000 (22:47 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 1 May 2010 22:47:00 +0000 (22:47 +0000)
commit6666e7634420f1133492fb04aa76d96f2c6994f8
treed4272ebd0813f6d10926194148d890dc26e2bdf1
parentd130025aa91750ba02ab1103c092a858d917271c
Add code to InternalIpcMemoryCreate() to handle the case where shmget()
returns EINVAL for an existing shared memory segment.  Although it's not
terribly sensible, that behavior does meet the POSIX spec because EINVAL
is the appropriate error code when the existing segment is smaller than the
requested size, and the spec explicitly disclaims any particular ordering of
error checks.  Moreover, it does in fact happen on OS X and probably other
BSD-derived kernels.  (We were able to talk NetBSD into changing their code,
but purging that behavior from the wild completely seems unlikely to happen.)
We need to distinguish collision with a pre-existing segment from invalid size
request in order to behave sensibly, so it's worth some extra code here to get
it right.  Per report from Gavin Kistner and subsequent investigation.

Back-patch to all supported versions, since any of them could get used
with a kernel having the debatable behavior.
src/backend/port/sysv_shmem.c