Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-10-2008, 02:01 PM
patrick keshishian
 
Posts: n/a
Default Re: Two patches for lib/libc/db/hash/hash.c

Not to come off as "pushy" but wanted to make sure these patches
didn't fall through the cracks, assuming they were rejected for
some reason.

Cheers,


On Sun, Apr 06, 2008 at 06:32:39PM -0700, patrick keshishian wrote:
> On Sun, Apr 06, 2008 at 09:39:20AM -0400, Todd C. Miller wrote:
> > In message <20080406082118.GA19070@roppongi.boxsoft.com>
> > so spake patrick keshishian (sidster):
> >
> > > Also, hashp->cndx is decremented (adjusted) during deletion of
> > > the key/data pair if hashp->cndx is pointing to the entry being
> > > deleted. The side-effect of not doing this is entries are
> > > skipped due to the way __delpair "shuffles" keys.

> >
> > Looks reasonable, though I wonder if it would not be better to do
> > the cndx fixup inside __delpair() for the shuffle case.

>
> Does this look OK?
>
>
> (Again hash.c diff is based on first patch in my original email)
>
> --- /usr/src/lib/libc/db/hash/hash.c Tue Aug 1 03:11:31 2006
> +++ hash/hash.c Sun Apr 6 18:18:38 2008
> @@ -705,7 +708,7 @@ hash_seq(const DB *dbp, DBT *key, DBT *data, u_int32_t
> hashp->cndx = 1;
> hashp->cpage = NULL;
> }
> -
> + next_bucket:
> for (bp = NULL; !bp || !bp[0]; ) {
> if (!(bufp = hashp->cpage)) {
> for (bucket = hashp->cbucket;
> @@ -724,8 +727,18 @@ hash_seq(const DB *dbp, DBT *key, DBT *data, u_int32_t
> hashp->cbucket = -1;
> return (ABNORMAL);
> }
> - } else
> + } else {
> bp = (u_int16_t *)hashp->cpage->page;
> + if (flag == R_NEXT) {
> + hashp->cndx += 2;
> + if (hashp->cndx > bp[0]) {
> + hashp->cpage = NULL;
> + hashp->cbucket++;
> + hashp->cndx = 1;
> + goto next_bucket;
> + }
> + }
> + }
>
> #ifdef DEBUG
> assert(bp);
> @@ -755,13 +768,6 @@ hash_seq(const DB *dbp, DBT *key, DBT *data, u_int32_t
> key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx];
> data->data = (u_char *)hashp->cpage->page + bp[ndx + 1];
> data->size = bp[ndx] - bp[ndx + 1];
> - ndx += 2;
> - if (ndx > bp[0]) {
> - hashp->cpage = NULL;
> - hashp->cbucket++;
> - hashp->cndx = 1;
> - } else
> - hashp->cndx = ndx;
> }
> return (SUCCESS);
> }
>
> --- /usr/src/lib/libc/db/hash/hash_page.c Fri Aug 5 06:03:00 2005
> +++ hash/hash_page.c Sun Apr 6 18:18:05 2008
> @@ -149,6 +149,14 @@ __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
> bp[i - 1] = bp[i + 1] + pairlen;
> }
> }
> + if (ndx == hashp->cndx) {
> + /*
> + * We just removed pair we were "pointing" to.
> + * By moving back the cndx we ensure subsequent
> + * hash_seq() calls won't skip over any entries.
> + */
> + hashp->cndx -= 2;
> + }
> }
> /* Finally adjust the page data */
> bp[n] = OFFSET(bp) + pairlen;


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:50 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145