Re: [exim] Exim with FreeBSD 8, dbm loop

Top Page
Delete this message
Reply to this message
Author: Xin LI
Date:  
To: Randy Bush
CC: Phil Pennock, exim-users, markm, delphij
Subject: Re: [exim] Exim with FreeBSD 8, dbm loop
Hi, Randy,

I believe that passing a non-zero flag is required by the API (as db(3)
says, the flags argument *must* be set). However, I don't think it's
good to break existing code and has committed a workaround as revision
196525:

Modified: head/lib/libc/db/hash/hash.c
==============================================================================
- --- head/lib/libc/db/hash/hash.c    Mon Aug 24 22:35:53 2009    (r196524)
+++ head/lib/libc/db/hash/hash.c    Mon Aug 24 23:44:07 2009    (r196525)
@@ -711,7 +711,7 @@ hash_seq(const DB *dbp, DBT *key, DBT *d
         hashp->cndx = 1;
         hashp->cpage = NULL;
     }
- - next_bucket:
+next_bucket:
     for (bp = NULL; !bp || !bp[0]; ) {
         if (!(bufp = hashp->cpage)) {
             for (bucket = hashp->cbucket;
@@ -732,7 +732,7 @@ hash_seq(const DB *dbp, DBT *key, DBT *d
             }
         } else {
             bp = (u_int16_t *)hashp->cpage->page;
- -            if (flag == R_NEXT) {
+            if (flag == R_NEXT || flag == 0) {
                 hashp->cndx += 2;
                 if (hashp->cndx > bp[0]) {
                     hashp->cpage = NULL;



I would propose the following change be applied to exim as well. Using
0 as flag is unsupported according to the manual page anyway:

- --- ./src/dbstuff.h.orig    2007-08-29 07:02:22.000000000 -0700
+++ ./src/dbstuff.h    2009-08-24 16:49:31.258232116 -0700
@@ -331,7 +331,7 @@


 /* EXIM_DBSCAN - returns TRUE if data is returned, FALSE at end */
 #define EXIM_DBSCAN(db, key, data, first, cursor)      \
- -       ((db)->seq(db, &key, &data, (first? R_FIRST : 0)) == 0)
+       ((db)->seq(db, &key, &data, (first? R_FIRST : R_NEXT)) == 0)


/* EXIM_DBDELETE_CURSOR - terminate scanning operation (null). Make it
refer to cursor, to keep picky compilers happy. */

By checking Kirk McKusick's CD with the SCCS history of BSD Unix I'd say
it's pretty safe to assume that R_NEXT would exist wherever R_FIRST existed.

Cheers,
- --
Xin LI <delphij@???>    http://www.delphij.net/
FreeBSD - The Power to Serve!