PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
shmqueue.c File Reference
#include "postgres.h"
#include "storage/shmem.h"
Include dependency graph for shmqueue.c:

Go to the source code of this file.

Functions

void SHMQueueInit (SHM_QUEUE *queue)
 
bool SHMQueueIsDetached (const SHM_QUEUE *queue)
 
void SHMQueueElemInit (SHM_QUEUE *queue)
 
void SHMQueueDelete (SHM_QUEUE *queue)
 
void SHMQueueInsertBefore (SHM_QUEUE *queue, SHM_QUEUE *elem)
 
void SHMQueueInsertAfter (SHM_QUEUE *queue, SHM_QUEUE *elem)
 
Pointer SHMQueueNext (const SHM_QUEUE *queue, const SHM_QUEUE *curElem, Size linkOffset)
 
Pointer SHMQueuePrev (const SHM_QUEUE *queue, const SHM_QUEUE *curElem, Size linkOffset)
 
bool SHMQueueEmpty (const SHM_QUEUE *queue)
 

Function Documentation

void SHMQueueDelete ( SHM_QUEUE queue)

Definition at line 68 of file shmqueue.c.

References Assert, SHM_QUEUE::next, SHM_QUEUE::prev, and ShmemAddrIsValid().

Referenced by CheckTargetForConflictsIn(), CleanUpLock(), ClearOldPredicateLocks(), CreatePredXact(), DeleteChildTargetLocks(), DeleteLockTarget(), DropAllPredicateLocksFromTable(), LockAcquireExtended(), PostPrepare_Locks(), ProcWakeup(), ReleaseOneSerializableXact(), ReleasePredXact(), ReleaseRWConflict(), RemoveFromWaitQueue(), SetPossibleUnsafeConflict(), SetRWConflict(), SummarizeOldestCommittedSxact(), SyncRepCancelWait(), SyncRepCleanupAtProcExit(), SyncRepWakeQueue(), and TransferPredicateLocksToNewTarget().

69 {
70  SHM_QUEUE *nextElem = queue->next;
71  SHM_QUEUE *prevElem = queue->prev;
72 
73  Assert(ShmemAddrIsValid(queue));
74  Assert(ShmemAddrIsValid(nextElem));
75  Assert(ShmemAddrIsValid(prevElem));
76 
77  prevElem->next = queue->next;
78  nextElem->prev = queue->prev;
79 
80  queue->prev = queue->next = NULL;
81 }
struct SHM_QUEUE * next
Definition: shmem.h:31
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:263
struct SHM_QUEUE * prev
Definition: shmem.h:30
#define Assert(condition)
Definition: c.h:664
void SHMQueueElemInit ( SHM_QUEUE queue)

Definition at line 57 of file shmqueue.c.

References Assert, SHM_QUEUE::next, SHM_QUEUE::prev, and ShmemAddrIsValid().

Referenced by GetSerializableTransactionSnapshotInt(), InitAuxiliaryProcess(), InitProcess(), MarkAsPreparingGuts(), and predicatelock_twophase_recover().

58 {
59  Assert(ShmemAddrIsValid(queue));
60  queue->prev = queue->next = NULL;
61 }
struct SHM_QUEUE * next
Definition: shmem.h:31
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:263
struct SHM_QUEUE * prev
Definition: shmem.h:30
#define Assert(condition)
Definition: c.h:664
bool SHMQueueEmpty ( const SHM_QUEUE queue)

Definition at line 180 of file shmqueue.c.

References Assert, FALSE, SHM_QUEUE::next, SHM_QUEUE::prev, ShmemAddrIsValid(), and TRUE.

Referenced by CheckForSerializableConflictOut(), CleanUpLock(), GetSafeSnapshot(), InitAuxiliaryProcess(), InitProcess(), lock_twophase_recover(), ProcKill(), ReleasePredicateLocks(), RemoveTargetIfNoLongerUsed(), RWConflictExists(), SetupLockInTable(), SummarizeOldestCommittedSxact(), and TransferPredicateLocksToNewTarget().

181 {
182  Assert(ShmemAddrIsValid(queue));
183 
184  if (queue->prev == queue)
185  {
186  Assert(queue->next == queue);
187  return TRUE;
188  }
189  return FALSE;
190 }
struct SHM_QUEUE * next
Definition: shmem.h:31
#define FALSE
Definition: c.h:219
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:263
struct SHM_QUEUE * prev
Definition: shmem.h:30
#define Assert(condition)
Definition: c.h:664
#define TRUE
Definition: c.h:215
void SHMQueueInit ( SHM_QUEUE queue)
void SHMQueueInsertAfter ( SHM_QUEUE queue,
SHM_QUEUE elem 
)

Definition at line 108 of file shmqueue.c.

References Assert, SHM_QUEUE::next, SHM_QUEUE::prev, and ShmemAddrIsValid().

Referenced by SyncRepQueueInsert().

109 {
110  SHM_QUEUE *nextPtr = queue->next;
111 
112  Assert(ShmemAddrIsValid(queue));
113  Assert(ShmemAddrIsValid(elem));
114 
115  elem->prev = nextPtr->prev;
116  elem->next = queue->next;
117  queue->next = elem;
118  nextPtr->prev = elem;
119 }
struct SHM_QUEUE * next
Definition: shmem.h:31
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:263
struct SHM_QUEUE * prev
Definition: shmem.h:30
#define Assert(condition)
Definition: c.h:664
void SHMQueueInsertBefore ( SHM_QUEUE queue,
SHM_QUEUE elem 
)

Definition at line 89 of file shmqueue.c.

References Assert, SHM_QUEUE::next, SHM_QUEUE::prev, and ShmemAddrIsValid().

Referenced by CreatePredicateLock(), CreatePredXact(), DeadLockCheck(), DropAllPredicateLocksFromTable(), InitPredicateLocks(), lock_twophase_recover(), PostPrepare_Locks(), ProcSleep(), ReleaseOneSerializableXact(), ReleasePredicateLocks(), ReleasePredXact(), ReleaseRWConflict(), SetPossibleUnsafeConflict(), SetRWConflict(), SetupLockInTable(), and TransferPredicateLocksToNewTarget().

90 {
91  SHM_QUEUE *prevPtr = queue->prev;
92 
93  Assert(ShmemAddrIsValid(queue));
94  Assert(ShmemAddrIsValid(elem));
95 
96  elem->next = prevPtr->next;
97  elem->prev = queue->prev;
98  queue->prev = elem;
99  prevPtr->next = elem;
100 }
struct SHM_QUEUE * next
Definition: shmem.h:31
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:263
struct SHM_QUEUE * prev
Definition: shmem.h:30
#define Assert(condition)
Definition: c.h:664
bool SHMQueueIsDetached ( const SHM_QUEUE queue)

Definition at line 47 of file shmqueue.c.

References Assert, SHM_QUEUE::prev, and ShmemAddrIsValid().

Referenced by SyncRepCancelWait(), SyncRepCleanupAtProcExit(), and SyncRepWaitForLSN().

48 {
49  Assert(ShmemAddrIsValid(queue));
50  return (queue->prev == NULL);
51 }
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:263
struct SHM_QUEUE * prev
Definition: shmem.h:30
#define Assert(condition)
Definition: c.h:664
Pointer SHMQueuePrev ( const SHM_QUEUE queue,
const SHM_QUEUE curElem,
Size  linkOffset 
)

Definition at line 164 of file shmqueue.c.

References Assert, SHM_QUEUE::prev, and ShmemAddrIsValid().

Referenced by SyncRepQueueInsert().

165 {
166  SHM_QUEUE *elemPtr = curElem->prev;
167 
168  Assert(ShmemAddrIsValid(curElem));
169 
170  if (elemPtr == queue) /* back to the queue head? */
171  return NULL;
172 
173  return (Pointer) (((char *) elemPtr) - linkOffset);
174 }
char * Pointer
Definition: c.h:235
bool ShmemAddrIsValid(const void *addr)
Definition: shmem.c:263
struct SHM_QUEUE * prev
Definition: shmem.h:30
#define Assert(condition)
Definition: c.h:664