From: Howard Chu Date: Tue, 24 Jul 2007 14:02:37 +0000 (+0000) Subject: Quick and dirty BDB 4.6.18 support. Expect this to change again soon. X-Git-Tag: OPENLDAP_REL_ENG_2_4_MP~296 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b514b257955c19a2e45771cfccf0b6363e04bd2f;p=openldap Quick and dirty BDB 4.6.18 support. Expect this to change again soon. --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index d564bfedfc..bf3c6ab825 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -275,6 +275,21 @@ struct bdb_op_info { #endif +/* 4.6.18 redefines cursor->locker */ +#if DB_VERSION_FULL >= 0x04060012 + +struct __db_locker { + u_int32_t id; +}; + +#define CURSOR_SETLOCKER(cursor, id) \ + __lock_getlocker(cursor->dbp->dbenv->lk_handle, id, 0, &cursor->locker) +#define CURSOR_GETLOCKER(cursor) cursor->locker->id +#else +#define CURSOR_SETLOCKER(cursor, id) cursor->locker = id +#define CURSOR_GETLOCKER(cursor) cursor->locker +#endif + #ifndef DB_BUFFER_SMALL #define DB_BUFFER_SMALL ENOMEM #endif diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 07acfeb2d5..2a64cb5c96 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -738,7 +738,7 @@ hdb_dn2id_parent( rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags ); if ( rc ) return rc; if ( !txn && locker ) { - cursor->locker = locker; + CURSOR_SETLOCKER(cursor, locker); } data.ulen = sizeof(diskNode) + (SLAP_LDAPDN_MAXLEN * 2); diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index d7d4c9bb2d..e66357cb10 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -121,8 +121,9 @@ int bdb_id2entry( if ( rc ) return rc; /* Use our own locker if needed */ - if ( !tid && locker ) - cursor->locker = locker; + if ( !tid && locker ) { + CURSOR_SETLOCKER( cursor, locker ); + } /* Get the nattrs / nvals counts first */ data.ulen = data.dlen = sizeof(buf); diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index c84486d790..8f52540bd1 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -559,7 +559,7 @@ bdb_idl_fetch_key( "cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 ); return rc; } - cursor->locker = locker; + CURSOR_SETLOCKER( cursor, locker ); } else { cursor = *saved_cursor; } diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 7bf5725a89..e95ca16594 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -319,7 +319,7 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id ) op.o_tmpmemctx = NULL; op.o_tmpmfuncs = &ch_mfuncs; - rc = bdb_cache_find_parent( &op, NULL, cursor->locker, id, &ei ); + rc = bdb_cache_find_parent( &op, NULL, CURSOR_GETLOCKER(cursor), id, &ei ); if ( rc == LDAP_SUCCESS ) { bdb_cache_entryinfo_unlock( ei ); e->e_private = ei;