From: Hallvard Furuseth Date: Mon, 12 Sep 2011 13:58:43 +0000 (+0200) Subject: Tweak back-mdb integer types to match libmdb. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=141a43c1ee1bce788459353e68653dd3b242ff24;p=openldap Tweak back-mdb integer types to match libmdb. Also do not cast between berval and MDB_val. That breaks when sizeof(berval.bv_len) != sizeof(MDB_val.mv_size). --- diff --git a/servers/slapd/back-mdb/attr.c b/servers/slapd/back-mdb/attr.c index 9b7a4a9772..0e32c67320 100644 --- a/servers/slapd/back-mdb/attr.c +++ b/servers/slapd/back-mdb/attr.c @@ -526,6 +526,7 @@ int mdb_ad_read( struct mdb_info *mdb, MDB_txn *txn ) int i, rc; MDB_cursor *mc; MDB_val key, data; + struct berval bdata; const char *text; AttributeDescription *ad; @@ -545,10 +546,12 @@ int mdb_ad_read( struct mdb_info *mdb, MDB_txn *txn ) rc = mdb_cursor_get( mc, &key, &data, MDB_SET ); while ( rc == MDB_SUCCESS ) { + bdata.bv_len = data.mv_size; + bdata.bv_val = data.mv_data; ad = NULL; - rc = slap_bv2ad( (struct berval *)&data, &ad, &text ); + rc = slap_bv2ad( &bdata, &ad, &text ); if ( rc ) { - rc = slap_bv2undef_ad( (struct berval *)&data, &mdb->mi_ads[i], &text, 0 ); + rc = slap_bv2undef_ad( &bdata, &mdb->mi_ads[i], &text, 0 ); } else { mdb->mi_adxs[ad->ad_index] = i; mdb->mi_ads[i] = ad; @@ -570,7 +573,7 @@ done: int mdb_ad_get( struct mdb_info *mdb, MDB_txn *txn, AttributeDescription *ad ) { int i, rc; - MDB_val key; + MDB_val key, val; rc = mdb_ad_read( mdb, txn ); if (rc) @@ -582,8 +585,10 @@ int mdb_ad_get( struct mdb_info *mdb, MDB_txn *txn, AttributeDescription *ad ) i = mdb->mi_numads+1; key.mv_size = sizeof(int); key.mv_data = &i; + val.mv_size = ad->ad_cname.bv_len; + val.mv_data = ad->ad_cname.bv_val; - rc = mdb_put( txn, mdb->mi_ad2id, &key, (MDB_val *)&ad->ad_cname, 0 ); + rc = mdb_put( txn, mdb->mi_ad2id, &key, &val, 0 ); if ( rc == MDB_SUCCESS ) { mdb->mi_adxs[ad->ad_index] = i; mdb->mi_ads[i] = ad; diff --git a/servers/slapd/back-mdb/config.c b/servers/slapd/back-mdb/config.c index 4041fabac6..b21dbee35e 100644 --- a/servers/slapd/back-mdb/config.c +++ b/servers/slapd/back-mdb/config.c @@ -60,7 +60,7 @@ static ConfigTable mdbcfg[] = { "DESC 'Attribute index parameters' " "EQUALITY caseIgnoreMatch " "SYNTAX OMsDirectoryString )", NULL, NULL }, - { "maxreaders", "num", 2, 2, 0, ARG_INT|ARG_MAGIC|MDB_MAXREADERS, + { "maxreaders", "num", 2, 2, 0, ARG_UINT|ARG_MAGIC|MDB_MAXREADERS, mdb_cf_gen, "( OLcfgDbAt:12.1 NAME 'olcDbMaxReaders' " "DESC 'Maximum number of threads that may access the DB concurrently' " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c index 008537d08c..408365a3fe 100644 --- a/servers/slapd/back-mdb/dn2id.c +++ b/servers/slapd/back-mdb/dn2id.c @@ -562,7 +562,7 @@ mdb_dn2id_children( rc = mdb_cursor_get( cursor, &key, &data, MDB_SET ); if ( rc == 0 ) { - unsigned long dkids; + size_t dkids; rc = mdb_cursor_count( cursor, &dkids ); if ( rc == 0 ) { if ( dkids < 2 ) rc = MDB_NOTFOUND; diff --git a/servers/slapd/back-mdb/idl.c b/servers/slapd/back-mdb/idl.c index 35c854ddb7..4dbc2e5ba2 100644 --- a/servers/slapd/back-mdb/idl.c +++ b/servers/slapd/back-mdb/idl.c @@ -421,7 +421,7 @@ mdb_idl_insert_keys( memcpy(&lo, data.mv_data, sizeof(ID)); if ( lo != 0 ) { /* not a range, count the number of items */ - unsigned long count; + size_t count; rc = mdb_cursor_count( cursor, &count ); if ( rc != 0 ) { err = "c_count"; diff --git a/servers/slapd/back-mdb/index.c b/servers/slapd/back-mdb/index.c index b4f7d56d16..15d59d6b22 100644 --- a/servers/slapd/back-mdb/index.c +++ b/servers/slapd/back-mdb/index.c @@ -27,6 +27,7 @@ static char presence_keyval[] = {0,0}; static struct berval presence_key[2] = {BER_BVC(presence_keyval), BER_BVNULL}; +static MDB_val presence_mdbkey[2] = {{1, presence_keyval}, {0, NULL}}; AttrInfo *mdb_index_mask( Backend *be, @@ -190,7 +191,7 @@ static int indexer( keyfunc = mdb_idl_delete_keys; if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { - rc = keyfunc( mc, (MDB_val *)presence_key, id ); + rc = keyfunc( mc, presence_mdbkey, id ); if( rc ) { err = "presence"; goto done;