From c23851bbe060983cb688afbd9708602fc70fd1d0 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 30 Dec 2000 01:20:55 +0000 Subject: [PATCH] Paranoia about possible values of errno after a shmget/semget failure. In theory we should always get EEXIST if there's a key collision, but if the kernel code tests error conditions in a weird order, perhaps EACCES or EIDRM could occur too. --- src/backend/storage/ipc/ipc.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index ee1bd7aeab..b111e65cb0 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.57 2000/12/11 00:49:52 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.58 2000/12/30 01:20:55 tgl Exp $ * * NOTES * @@ -272,9 +272,14 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, /* * Fail quietly if error indicates a collision with existing set. * One would expect EEXIST, given that we said IPC_EXCL, but perhaps - * we could get a permission violation instead? + * we could get a permission violation instead? Also, EIDRM might + * occur if an old set is slated for destruction but not gone yet. */ - if (errno == EEXIST || errno == EACCES) + if (errno == EEXIST || errno == EACCES +#ifdef EIDRM + || errno == EIDRM +#endif + ) return -1; /* * Else complain and abort @@ -516,9 +521,14 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission) /* * Fail quietly if error indicates a collision with existing segment. * One would expect EEXIST, given that we said IPC_EXCL, but perhaps - * we could get a permission violation instead? + * we could get a permission violation instead? Also, EIDRM might + * occur if an old seg is slated for destruction but not gone yet. */ - if (errno == EEXIST || errno == EACCES) + if (errno == EEXIST || errno == EACCES +#ifdef EIDRM + || errno == EIDRM +#endif + ) return NULL; /* * Else complain and abort -- 2.40.0