Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c23851b

Browse files
committed
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.
1 parent 2153d1c commit c23851b

File tree

1 file changed

+15
-5
lines changed
  • src/backend/storage/ipc

1 file changed

+15
-5
lines changed

src/backend/storage/ipc/ipc.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.57 2000/12/11 00:49:52 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.58 2000/12/30 01:20:55 tgl Exp $
1212
*
1313
* NOTES
1414
*
@@ -272,9 +272,14 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey,
272272
/*
273273
* Fail quietly if error indicates a collision with existing set.
274274
* One would expect EEXIST, given that we said IPC_EXCL, but perhaps
275-
* we could get a permission violation instead?
275+
* we could get a permission violation instead? Also, EIDRM might
276+
* occur if an old set is slated for destruction but not gone yet.
276277
*/
277-
if (errno == EEXIST || errno == EACCES)
278+
if (errno == EEXIST || errno == EACCES
279+
#ifdef EIDRM
280+
|| errno == EIDRM
281+
#endif
282+
)
278283
return -1;
279284
/*
280285
* Else complain and abort
@@ -516,9 +521,14 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
516521
/*
517522
* Fail quietly if error indicates a collision with existing segment.
518523
* One would expect EEXIST, given that we said IPC_EXCL, but perhaps
519-
* we could get a permission violation instead?
524+
* we could get a permission violation instead? Also, EIDRM might
525+
* occur if an old seg is slated for destruction but not gone yet.
520526
*/
521-
if (errno == EEXIST || errno == EACCES)
527+
if (errno == EEXIST || errno == EACCES
528+
#ifdef EIDRM
529+
|| errno == EIDRM
530+
#endif
531+
)
522532
return NULL;
523533
/*
524534
* Else complain and abort

0 commit comments

Comments
 (0)