Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22fe3d4

Browse files
committed
I finally understood what sinvaladt.c is doing --- and it
offended my aesthestic sensibility that there was so much unreadable codedoing so little. Rewritten code is about half the size, faster, and(I hope) much more intelligible.
1 parentcc8b67a commit22fe3d4

File tree

4 files changed

+316
-820
lines changed

4 files changed

+316
-820
lines changed

‎src/backend/storage/ipc/sinval.c

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.17 1999/09/04 18:36:45 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.18 1999/09/06 19:37:38 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,12 +21,6 @@
2121
#include"storage/sinval.h"
2222
#include"storage/sinvaladt.h"
2323

24-
externSISeg*shmInvalBuffer;/* the shared buffer segment, set by
25-
* SISegmentAttach()
26-
*/
27-
externBackendIdMyBackendId;
28-
externBackendTagMyBackendTag;
29-
3024
SPINLOCKSInvalLock= (SPINLOCK)NULL;
3125

3226
/****************************************************************************/
@@ -39,11 +33,6 @@ CreateSharedInvalidationState(IPCKey key, int maxBackends)
3933
{
4034
intstatus;
4135

42-
/*
43-
* REMOVED SISyncKill(IPCKeyGetSIBufferMemorySemaphoreKey(key));
44-
* SISyncInit(IPCKeyGetSIBufferMemorySemaphoreKey(key));
45-
*/
46-
4736
/* SInvalLock gets set in spin.c, during spinlock init */
4837
status=SISegmentInit(true,IPCKeyGetSIBufferMemoryBlock(key),
4938
maxBackends);
@@ -53,9 +42,9 @@ CreateSharedInvalidationState(IPCKey key, int maxBackends)
5342
}
5443

5544
/****************************************************************************/
56-
/*AttachSharedInvalidationState(key) Attachabuffer segment*/
45+
/*AttachSharedInvalidationState(key) Attachto existingbuffer segment*/
5746
/**/
58-
/*should be calledonlybythe POSTMASTER*/
47+
/*should be called byeach backend during startup*/
5948
/****************************************************************************/
6049
void
6150
AttachSharedInvalidationState(IPCKeykey)
@@ -74,6 +63,11 @@ AttachSharedInvalidationState(IPCKey key)
7463
elog(FATAL,"AttachSharedInvalidationState: failed segment init");
7564
}
7665

66+
/*
67+
* InitSharedInvalidationState
68+
*Initialize new backend's state info in buffer segment.
69+
*Must be called after AttachSharedInvalidationState().
70+
*/
7771
void
7872
InitSharedInvalidationState(void)
7973
{
@@ -88,24 +82,19 @@ InitSharedInvalidationState(void)
8882

8983
/*
9084
* RegisterSharedInvalid
91-
*Returns anew localcacheinvalidationstate containing a new entry.
85+
*Add ashared-cache-invalidationmessage to the global SI message queue.
9286
*
9387
* Note:
9488
*Assumes hash index is valid.
9589
*Assumes item pointer is valid.
9690
*/
97-
/****************************************************************************/
98-
/*RegisterSharedInvalid(cacheId, hashIndex, pointer)*/
99-
/**/
100-
/*register a message in the buffer*/
101-
/*should be called by a backend*/
102-
/****************************************************************************/
10391
void
10492
RegisterSharedInvalid(intcacheId,/* XXX */
10593
IndexhashIndex,
10694
ItemPointerpointer)
10795
{
108-
SharedInvalidDatanewInvalid;
96+
SharedInvalidDatanewInvalid;
97+
boolinsertOK;
10998

11099
/*
111100
* This code has been hacked to accept two types of messages. This
@@ -127,34 +116,16 @@ RegisterSharedInvalid(int cacheId,/* XXX */
127116
ItemPointerSetInvalid(&newInvalid.pointerData);
128117

129118
SpinAcquire(SInvalLock);
130-
while (!SISetDataEntry(shmInvalBuffer,&newInvalid))
131-
{
132-
/* buffer full */
133-
/* release a message, mark process cache states to be invalid */
134-
SISetProcStateInvalid(shmInvalBuffer);
135-
136-
if (!SIDelDataEntries(shmInvalBuffer,1))
137-
{
138-
/* inconsistent buffer state -- shd never happen */
139-
SpinRelease(SInvalLock);
140-
elog(FATAL,"RegisterSharedInvalid: inconsistent buffer state");
141-
}
142-
143-
/* loop around to try write again */
144-
}
119+
insertOK=SIInsertDataEntry(shmInvalBuffer,&newInvalid);
145120
SpinRelease(SInvalLock);
121+
if (!insertOK)
122+
elog(NOTICE,"RegisterSharedInvalid: SI buffer overflow");
146123
}
147124

148125
/*
149126
* InvalidateSharedInvalid
150-
*Processes all entries in a shared cache invalidation state.
127+
*Process shared-cache-invalidation messages waiting for this backend
151128
*/
152-
/****************************************************************************/
153-
/*InvalidateSharedInvalid(invalFunction, resetFunction)*/
154-
/**/
155-
/*invalidate a message in the buffer (read and clean up)*/
156-
/*should be called by a backend*/
157-
/****************************************************************************/
158129
void
159130
InvalidateSharedInvalid(void (*invalFunction) (),
160131
void (*resetFunction) ())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp