diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-10-01 14:01:19 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-10-01 14:01:19 +0000 |
commit | 57e49a03de9505a0e78b3c554786afa6d9d3b400 (patch) | |
tree | 3ab962097e5efe8b9703f9587ccd10b7649c5678 /lib/libc/db | |
parent | 727ee34a79897a005fe18b14248d9f28994c4345 (diff) |
Avoid overwriting the cursor page when the cursor page becomes the
LRU page. From pacman at manson dot clss dot net.
ok deraadt@ millert@
Diffstat (limited to 'lib/libc/db')
-rw-r--r-- | lib/libc/db/hash/hash_buf.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index 224c1cace9f..c4a31d35c96 100644 --- a/lib/libc/db/hash/hash_buf.c +++ b/lib/libc/db/hash/hash_buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash_buf.c,v 1.12 2003/06/02 20:18:33 millert Exp $ */ +/* $OpenBSD: hash_buf.c,v 1.13 2004/10/01 14:01:18 otto Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94"; #else -static const char rcsid[] = "$OpenBSD: hash_buf.c,v 1.12 2003/06/02 20:18:33 millert Exp $"; +static const char rcsid[] = "$OpenBSD: hash_buf.c,v 1.13 2004/10/01 14:01:18 otto Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -174,11 +174,19 @@ newbuf(hashp, addr, prev_bp) oaddr = 0; bp = LRU; + + /* It is bad to overwrite the page under the cursor. */ + if (bp == hashp->cpage) { + BUF_REMOVE(bp); + MRU_INSERT(bp); + bp = LRU; + } + /* * If LRU buffer is pinned, the buffer pool is too small. We need to * allocate more buffers. */ - if (hashp->nbufs || (bp->flags & BUF_PIN)) { + if (hashp->nbufs || (bp->flags & BUF_PIN) || bp == hashp->cpage) { /* Allocate a new one */ if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL) return (NULL); |