Paranoia about possible values of errno after a shmget/semget failure.
authorTom Lane
Sat, 30 Dec 2000 01:20:55 +0000 (01:20 +0000)
committerTom Lane
Sat, 30 Dec 2000 01:20:55 +0000 (01:20 +0000)
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

index ee1bd7aeab1226630ed504b3b1cebcb1d17ac0ee..b111e65cb06389c95525fd2ebe19310e58a4c571 100644 (file)
@@ -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