1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Clean up non-reentrant interface for hash_seq/HashTableWalk, so that

starting a new hashtable search no longer clobbers any other search
active anywhere in the system.  Fix RelationCacheInvalidate() so that
it will not crash or go into an infinite loop if invoked recursively,
as for example by a second SI Reset message arriving while we are still
processing a prior one.
This commit is contained in:
Tom Lane
2001-01-02 04:33:24 +00:00
parent 25d88e4c53
commit 1b8a219eef
8 changed files with 149 additions and 158 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/hasht.c,v 1.13 2000/01/31 04:35:51 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/hasht.c,v 1.14 2001/01/02 04:33:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -21,23 +21,32 @@
/* -----------------------------------
* HashTableWalk
*
* call function on every element in hashtable
* one extra argument (arg) may be supplied
* call given function on every element in hashtable
*
* one extra argument (arg) may be supplied
*
* NOTE: it is allowed for the given function to delete the hashtable entry
* it is passed. However, deleting any other element while the scan is
* in progress is UNDEFINED (see hash_seq functions). Also, if elements are
* added to the table while the scan is in progress, it is unspecified
* whether they will be visited by the scan or not.
* -----------------------------------
*/
void
HashTableWalk(HTAB *hashtable, HashtFunc function, int arg)
HashTableWalk(HTAB *hashtable, HashtFunc function, Datum arg)
{
HASH_SEQ_STATUS status;
long *hashent;
void *data;
int keysize;
hash_seq_init(&status, hashtable);
keysize = hashtable->hctl->keysize;
hash_seq((HTAB *) NULL);
while ((hashent = hash_seq(hashtable)) != (long *) TRUE)
while ((hashent = hash_seq_search(&status)) != (long *) TRUE)
{
if (hashent == NULL)
elog(FATAL, "error in HashTableWalk.");
elog(FATAL, "error in HashTableWalk");
/*
* XXX the corresponding hash table insertion does NOT LONGALIGN