Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Berkely DB > Is DB_HASH sup*...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1767 of 1804
Post > Topic >>

Is DB_HASH sup****t broken in BerkeleyDB 4.6.19 ?

by "Gregory P. Smith" <gpsmith@[EMAIL PROTECTED] > Sep 8, 2007 at 11:31 PM

On both Linux and Mac OS X 10.4.9 the following simple code to write
values into a DB_HASH database locks up when compiled with BerkeleyDB
4.6.19.  It works fine when compiled against 4.5.  Why?


#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <db.h>

int main()
{
    DB_ENV *db_env = NULL;
    DB *db = NULL;
    char *db_home;
    char tmpstr[128];
    char keystr[5];
    char datastr[30];
    DBT key = { 0 };
    DBT data = { 0 };
    int err, x;

    strncpy(tmpstr, "/tmp/cdbtest.XXXXXX", sizeof(tmpstr)-1);
    db_home = mkdtemp(tmpstr);
    printf("running in %s.\n", db_home);

    err = db_env_create(&db_env, 0);
    if (err) { printf("a: %s\n", db_strerror(err)); goto errorexit; }
    err = db_env->open(db_env, db_home,
             DB_CREATE | DB_THREAD | DB_INIT_CDB | DB_INIT_MPOOL,
0660);
    if (err) { printf("b: %s\n", db_strerror(err)); goto errorexit; }
    err = db_create(&db, db_env, 0);
    if (err) { printf("c: %s\n", db_strerror(err)); goto errorexit; }
    err = db->open(db, NULL, "cdbtest", NULL, DB_HASH, DB_CREATE |
DB_THREAD, 0660);
    if (err) { printf("d: %s\n", db_strerror(err)); goto errorexit; }
    for (x = 0; x < 1000; ++x) {
        snprintf(keystr,sizeof(keystr),"%04x",x);
        key.data = keystr;
        key.size = strlen(keystr);

        snprintf(datastr,sizeof(datastr),"%04x-%04x-%04x-%04x-
%04x",x,x,x,x,x);
        data.data = datastr;
        data.size = strlen(datastr);

        err = db->put(db, NULL, &key, &data, 0);
        if (err) { printf("e: %s\n", db_strerror(err)); goto
errorexit; }
        if (x % 50 == 0)
            printf("put with x = %d\n", x);
    }
    db->close(db, 0);
    db_env->remove(db_env, db_home, DB_FORCE);
    printf("done.\n");
    printf("remember to rm -r %s\n", db_home);

    return 0;

errorexit:
    if (db)
        db->close(db, 0);
    if (db_env)
        db_env->remove(db_env, db_home, DB_FORCE);
    return 1;
}
 




 1 Posts in Topic:
Is DB_HASH sup****t broken in BerkeleyDB 4.6.19 ?
"Gregory P. Smith&q  2007-09-08 23:31:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 6:36:15 CDT 2008.