summaryrefslogtreecommitdiffstats
path: root/lib/libc/db
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-03-28 06:38:31 +0000
committerdelphij <delphij@FreeBSD.org>2009-03-28 06:38:31 +0000
commit8d5f207dd117429b795e3fe026c15e8cf8721520 (patch)
tree24e190980bd4567b85a3c32895463bdf393d0e53 /lib/libc/db
parentbe23f69f403b512b59926d78baae02cd2fb18778 (diff)
downloadFreeBSD-src-8d5f207dd117429b795e3fe026c15e8cf8721520.zip
FreeBSD-src-8d5f207dd117429b795e3fe026c15e8cf8721520.tar.gz
- Avoid overwriting the cursor page when the cursor page becomes the
LRU page. - Fix for sequential retrieval failure when using large key/data pairs. Obtained from: OpenBSD
Diffstat (limited to 'lib/libc/db')
-rw-r--r--lib/libc/db/hash/hash_buf.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c
index 8741ea5..6d26b16 100644
--- a/lib/libc/db/hash/hash_buf.c
+++ b/lib/libc/db/hash/hash_buf.c
@@ -164,11 +164,31 @@ newbuf(HTAB *hashp, u_int32_t addr, BUFHEAD *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 prev_bp is part of bp overflow, create a new buffer. */
+ if (hashp->nbufs == 0 && prev_bp && bp->ovfl) {
+ BUFHEAD *ovfl;
+
+ for (ovfl = bp->ovfl; ovfl ; ovfl = ovfl->ovfl) {
+ if (ovfl == prev_bp) {
+ hashp->nbufs++;
+ break;
+ }
+ }
+ }
+
/*
* 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 *)calloc(1, sizeof(BUFHEAD))) == NULL)
return (NULL);
OpenPOWER on IntegriCloud