aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/ipc/sinval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/ipc/sinval.c')
-rw-r--r--src/backend/storage/ipc/sinval.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c
index 570feab25e6..856d0f0a73f 100644
--- a/src/backend/storage/ipc/sinval.c
+++ b/src/backend/storage/ipc/sinval.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.63 2004/05/23 03:50:45 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.64 2004/06/02 21:29:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -464,6 +464,40 @@ TransactionIdIsInProgress(TransactionId xid)
}
/*
+ * IsBackendPid -- is a given pid a running backend
+ */
+bool
+IsBackendPid(int pid)
+{
+ bool result = false;
+ SISeg *segP = shmInvalBuffer;
+ ProcState *stateP = segP->procState;
+ int index;
+
+ LWLockAcquire(SInvalLock, LW_SHARED);
+
+ for (index = 0; index < segP->lastBackend; index++)
+ {
+ SHMEM_OFFSET pOffset = stateP[index].procStruct;
+
+ if (pOffset != INVALID_OFFSET)
+ {
+ PGPROC *proc = (PGPROC *) MAKE_PTR(pOffset);
+
+ if (proc->pid == pid)
+ {
+ result = true;
+ break;
+ }
+ }
+ }
+
+ LWLockRelease(SInvalLock);
+
+ return result;
+}
+
+/*
* GetOldestXmin -- returns oldest transaction that was running
* when any current transaction was started.
*