mirror of
https://github.com/postgres/postgres.git
synced 2025-05-18 17:41:14 +03:00
In PGSharedMemoryIsInUse, assume that EACCES indicates a shmem segment
that is of no concern to us --- it must belong to a different userid, which means it is not a Postgres shmem segment (or at least, not one that is relevant to our data directory). I plan a more extensive fix in HEAD, but this is a simple change that prevents failure-to-reboot problems for single-postmaster installations.
This commit is contained in:
parent
3392959b6e
commit
176bb0812f
@ -10,7 +10,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.24.2.1 2003/11/07 21:56:01 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.24.2.2 2004/11/09 20:35:16 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -191,10 +191,6 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
|
|||||||
/*
|
/*
|
||||||
* We detect whether a shared memory segment is in use by seeing
|
* We detect whether a shared memory segment is in use by seeing
|
||||||
* whether it (a) exists and (b) has any processes are attached to it.
|
* whether it (a) exists and (b) has any processes are attached to it.
|
||||||
*
|
|
||||||
* If we are unable to perform the stat operation for a reason other than
|
|
||||||
* nonexistence of the segment (most likely, because it doesn't belong
|
|
||||||
* to our userid), assume it is in use.
|
|
||||||
*/
|
*/
|
||||||
if (shmctl(shmId, IPC_STAT, &shmStat) < 0)
|
if (shmctl(shmId, IPC_STAT, &shmStat) < 0)
|
||||||
{
|
{
|
||||||
@ -205,7 +201,18 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
|
|||||||
*/
|
*/
|
||||||
if (errno == EINVAL)
|
if (errno == EINVAL)
|
||||||
return false;
|
return false;
|
||||||
/* Else assume segment is in use */
|
/*
|
||||||
|
* EACCES implies that the segment belongs to some other userid,
|
||||||
|
* which means it is not a Postgres shmem segment (or at least,
|
||||||
|
* not one that is relevant to our data directory).
|
||||||
|
*/
|
||||||
|
if (errno == EACCES)
|
||||||
|
return false;
|
||||||
|
/*
|
||||||
|
* Otherwise, we had better assume that the segment is in use.
|
||||||
|
* The only likely case is EIDRM, which implies that the segment
|
||||||
|
* has been IPC_RMID'd but there are still processes attached to it.
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/* If it has attached processes, it's in use */
|
/* If it has attached processes, it's in use */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user