summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormontulli <devnull@localhost>1998-06-11 22:26:49 +0000
committermontulli <devnull@localhost>1998-06-11 22:26:49 +0000
commit5f00ff35bf8d6d3e5d54037323da7a1c404fd336 (patch)
treecc02b5d27ddb263caf3cbdb308a2bebde1307f81
parentfd2eb6e4f746dabb6172ebe44d6687c9e4c44efd (diff)
downloadnss-hg-5f00ff35bf8d6d3e5d54037323da7a1c404fd336.tar.gz
add dirty_bit functionality to database to keep it from saving out when
it's not necessary. Squid will stop harrassing me now
-rw-r--r--dbm/include/hash.h1
-rw-r--r--dbm/src/hash.c7
2 files changed, 7 insertions, 1 deletions
diff --git a/dbm/include/hash.h b/dbm/include/hash.h
index b898fe048..4db5d44f2 100644
--- a/dbm/include/hash.h
+++ b/dbm/include/hash.h
@@ -123,6 +123,7 @@ typedef struct htab { /* Memory resident data structure */
int save_file; /* Indicates whether we need to flush
* file at
* exit */
+ int dirty_bit; /* has db changed */
uint32 *mapp[NCACHED]; /* Pointers to page maps */
int nmaps; /* Initial number of bitmaps */
int nbufs; /* Number of buffers left to
diff --git a/dbm/src/hash.c b/dbm/src/hash.c
index c8e9a234f..56dd1045f 100644
--- a/dbm/src/hash.c
+++ b/dbm/src/hash.c
@@ -161,6 +161,7 @@ __hash_open(const char *file, int flags, int mode, const HASHINFO *info, int dfl
if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB))))
RETURN_ERROR(ENOMEM, error0);
hashp->fp = NO_FILE;
+ hashp->dirty_bit = 0;
if(file)
hashp->filename = strdup(file);
@@ -611,7 +612,7 @@ flush_meta(HTAB *hashp)
#endif
int fp, i, wsize;
- if (!hashp->save_file)
+ if (!hashp->save_file || !hashp->dirty_bit)
return (0);
hashp->MAGIC = HASHMAGIC;
hashp->VERSION = HASHVERSION;
@@ -695,6 +696,8 @@ hash_put(
if (!hashp)
return (DBM_ERROR);
+ hashp->dirty_bit = 1;
+
if (flag && flag != R_NOOVERWRITE) {
hashp->dbmerrno = errno = EINVAL;
return (DBM_ERROR);
@@ -731,6 +734,8 @@ hash_delete(
if (!hashp)
return (DBM_ERROR);
+ hashp->dirty_bit = 1;
+
if (flag && flag != R_CURSOR) {
hashp->dbmerrno = errno = EINVAL;
return (DBM_ERROR);