[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: db4



There are some version checks in the OpenLDAP 2.0.18 code that are wrong for
Berkeley DB 4. One of these checks is fixed in the 2.0.19 release, you should
probably upgrade your source to 2.0.19. (There are other bug fixes in 2.0.19
that you'll want as well.)

The 2.0.19 source is missing one additional version fix, but I don't believe
that will cause any serious problem. (The ldbm library wants to set its own
malloc handler in Berkeley DB but it won't get set at all in 2.0.19 on BDB4.)
The ldbm_malloc routine just uses calloc instead of malloc; whether anything
else actually depends on the returned memory to be zeroed is unclear to me.

This is a diff of the 2.0.18 libraries/libldbm/ldbm.c code against the 2.0.19
version:

--- ldbm.c      2001/10/12 22:27:35     1.30.8.20
+++ ldbm.c      2001/12/07 16:14:54     1.30.8.21
@@ -1,5 +1,5 @@
 /* ldbm.c - ldap dbm compatibility routines */
-/* $OpenLDAP: pkg/ldap/libraries/libldbm/ldbm.c,v 1.30.8.20 2001/10/12
22:27:35
 kurt Exp $ */
+/* $OpenLDAP: pkg/ldap/libraries/libldbm/ldbm.c,v 1.30.8.21 2001/12/07
16:14:54
 kurt Exp $ */
 /*
  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -315,7 +315,7 @@
                return NULL;
        }

-#if DB_VERSION_MINOR < 3
+#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR < 3
        ret->set_malloc( ret, ldbm_malloc );
 #endif

As you can see, this fix is relatively simple. This is a diff of 2.0.19 against
the current development branch; the diff is longer but the relevant changes are
again very simple. The specific change you need is in lines 229-231 of ldbm.c.
The remainder of the diff simply collapses BDB version 2 support into version 3
support where the APIs are identical. I expect the rest of these diffs to be
rolled into the next release, whenever that is.

--- ldbm.c      2001/12/07 16:14:54     1.30.8.21
+++ ldbm.c      2001/12/10 15:26:32     1.71
@@ -1,5 +1,5 @@
 /* ldbm.c - ldap dbm compatibility routines */
-/* $OpenLDAP: pkg/ldap/libraries/libldbm/ldbm.c,v 1.30.8.21 2001/12/07
16:14:54
 kurt Exp $ */
+/* $OpenLDAP: pkg/ldap/libraries/libldbm/ldbm.c,v 1.71 2001/12/10 15:26:32 hyc
Exp $ */
 /*
  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -120,8 +120,10 @@

 int ldbm_initialize( const char* home )
 {
+#if DB_VERSION_MAJOR < 3
        int     err;
        u_int32_t       envFlags;
+#endif

        if(ldbm_initialized++) return 1;

@@ -229,7 +231,8 @@
                return NULL;
        }

-#if DB_VERSION_MINOR >= 3
+#if DB_VERSION_MAJOR > 3 || DB_VERSION_MINOR >= 3
+       /* This interface appeared in 3.3 */
        env->set_alloc( env, ldbm_malloc, NULL, NULL );
 #endif

@@ -389,12 +392,10 @@
 ldbm_close( LDBM ldbm )
 {
        LDBM_WLOCK;
-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
        ldbm->close( ldbm, 0 );
-#elif DB_VERSION_MAJOR >= 2
-       (*ldbm->close)( ldbm, 0 );
 #else
-       (*ldbm->close)( ldbm );
+       ldbm->close( ldbm );
 #endif
        LDBM_WUNLOCK;
 }
@@ -415,7 +416,7 @@

        LDBM_RLOCK;

-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
        ldbm_datum_init( data );

        data.flags = DB_DBT_MALLOC;
@@ -425,20 +426,8 @@
                data.dptr = NULL;
                data.dsize = 0;
        }
-
-#elif DB_VERSION_MAJOR >= 2
-       ldbm_datum_init( data );
-
-       data.flags = DB_DBT_MALLOC;
-
-       if ( (rc = (*ldbm->get)( ldbm, NULL, &key, &data, 0 )) != 0 ) {
-               ldbm_datum_free( ldbm, data );
-               data.dptr = NULL;
-               data.dsize = 0;
-       }
 #else
-
-       if ( (rc = (*ldbm->get)( ldbm, &key, &data, 0 )) == 0 ) {
+       if ( (rc = ldbm->get( ldbm, &key, &data, 0 )) == 0 ) {
                /* Berkeley DB 1.85 don't malloc the data for us */
                /* duplicate it for to ensure reentrancy */
                data = ldbm_datum_dup( ldbm, data );
@@ -460,19 +449,15 @@

        LDBM_WLOCK;

-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
        rc = ldbm->put( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC );
        rc = (-1) * rc;
-
-#elif DB_VERSION_MAJOR >= 2
-       rc = (*ldbm->put)( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC );
-       rc = (-1) * rc;
 #else
-       rc = (*ldbm->put)( ldbm, &key, &data, flags & ~LDBM_SYNC );
+       rc = ldbm->put( ldbm, &key, &data, flags & ~LDBM_SYNC );
 #endif

        if ( flags & LDBM_SYNC )
-               (*ldbm->sync)( ldbm, 0 );
+               ldbm->sync( ldbm, 0 );

        LDBM_WUNLOCK;

@@ -486,16 +471,13 @@

        LDBM_WLOCK;

-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR >= 2
        rc = ldbm->del( ldbm, NULL, &key, 0 );
        rc = (-1) * rc;
-#elif DB_VERSION_MAJOR >= 2
-       rc = (*ldbm->del)( ldbm, NULL, &key, 0 );
-       rc = (-1) * rc;
 #else
-       rc = (*ldbm->del)( ldbm, &key, 0 );
+       rc = ldbm->del( ldbm, &key, 0 );
 #endif
-       (*ldbm->sync)( ldbm, 0 );
+       ldbm->sync( ldbm, 0 );

        LDBM_WUNLOCK;

@@ -519,20 +501,17 @@
        LDBM_RLOCK;

        /* acquire a cursor for the DB */
-# if DB_VERSION_MAJOR >= 3
+# if DB_VERSION_MAJOR >= 3 || (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR > 5)
        rc = ldbm->cursor( ldbm, NULL, &dbci, 0 );
-# elif defined( DB_VERSION_MAJOR ) && defined( DB_VERSION_MINOR ) && \
-       (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 6)
-       rc = (*ldbm->cursor)( ldbm, NULL, &dbci );
 # else
-       rc = (*ldbm->cursor)( ldbm, NULL, &dbci, 0 );
+       rc = ldbm->cursor( ldbm, NULL, &dbci );
 # endif

        if( rc ) {
                key.dptr = NULL;
        } else {
                *dbch = dbci;
-               if ( (*dbci->c_get)( dbci, &key, &data, DB_NEXT ) == 0 ) {
+               if ( dbci->c_get( dbci, &key, &data, DB_NEXT ) == 0 ) {
                        ldbm_datum_free( ldbm, data );
                } else {
                        key.dptr = NULL;
@@ -545,7 +524,7 @@
 #else
        LDBM_RLOCK;

-       rc = (*ldbm->seq)( ldbm, &key, &data, R_FIRST );
+       rc = ldbm->seq( ldbm, &key, &data, R_FIRST );

        if ( rc == 0 ) {
                key = ldbm_datum_dup( ldbm, key );
@@ -574,12 +553,12 @@
        ldbm_datum_free( ldbm, key );
        key.flags = data.flags = DB_DBT_MALLOC;

-       rc = (*dbcp->c_get)( dbcp, &key, &data, DB_NEXT );
+       rc = dbcp->c_get( dbcp, &key, &data, DB_NEXT );
        if ( rc == 0 ) {
                ldbm_datum_free( ldbm, data );
        } else
 #else
-       rc = (*ldbm->seq)( ldbm, &key, &data, R_NEXT );
+       rc = ldbm->seq( ldbm, &key, &data, R_NEXT );

        if ( rc == 0 ) {
                key = ldbm_datum_dup( ldbm, key );

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support

> -----Original Message-----
> From: owner-openldap-software@OpenLDAP.org
> [mailto:owner-openldap-software@OpenLDAP.org]On Behalf Of Taymour A. El
> Erian
> Sent: Sunday, December 23, 2001 3:43 AM
> To: openldap-software@OpenLDAP.org
> Subject: db4
>
>
> Hi,
> 	I am installing openldap 2.0.18 with Berkeley db4, the
> compilation of db4
> went ok and I created symbolic link db.h to db.h of db4 also libldap.so
> to libldap-4.0.so and compiled openldap and the compilation was successful.
> The problem is openldap doesn't start giving an error about the bi_open
> function.
> Can anyone help.
> --
> Taymour A El Erian
> Senior system engineer
> GEGA NET
> www.gega.net
>
>