Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Berkeley DB problems

4003rd creation environment :
If ((ret = db_env_create (&dbenv_read, 0))> 0) (
Return (ret);
        }
4003rd installed timeout time
If ((ret = dbenv_read->set_timeout (dbenv_read, 900000, DB_SET_LOCK_TIMEOUT))> 0) (
Return (ret);
        }
       
4003rd open environment
If ((ret = dbenv_read->open (dbenv_read that. " / "DB_CREATE | DB_INIT_MPOOL, 0))> 0) (
Goto err;
        }       
4003rd made state value, which exists statp
Ret = dbenv_read->lock_stat (dbenv_read, statp, DB_STAT_CLEAR);
If (ret> 0) (
Goto err;
    }


In the first round of state Radio wrong, wrong timeout value. What are the reasons?

There's ah?

No dbenv_read api.
Packaging your own bar.
Http://berkeleydb.net/man/bdb/api_c/env_set_timeout.html

Set_timeout first open another try.

That is my own definition : DB_ENV dbenv_read *dbenv_read;

If I have the procedures in the case, the operation appeared to dbenv_read->lock_stat wrong, if the first set_timeout open again, the same sentence, but there would be mistakes set_timeout function.

Set_timeout I followed closely behind with a get_timeout function, it can. But lock_stat function Why not?

I did not flag in the open position with DB_INIT_LOCK parameters, and this is not there?
However, I do not function so that after adding the open-how else?

DB_CREATE | DB_INIT_MPOOL
Only these two signs is not enough. Must have used the locking subsystem.
I do not know if you are not using the services operating.

Open function is not so, it is impossible.
You can earn under the affairs of the practice.
Manual should be.

Set_timeout I followed closely behind with a get_timeout function, we can obtain the value of the timeout, but we will not open function of the environment, how else?

I initially suggested this issue.

Not explain, stickers months minimum, the operational code out.

Code stickers out, and then help me find bars.
[code]
#include "Stdio.h>
#include "Stdlib.h>
#include "String.h>
#include "Pthread.h>
#include "Db.h>
#include "Unistd.h>
Void init_DBT (DBT * key, DBT * data)
{
Memset (key, 0, sizeof (DBT));
Memset (data, 0, sizeof (DBT));
}

Int main ()
{

DB_ENV *dbenv_read;
DB *dbp;
DBT key, the data;
Int ret;
U_int32_t open_flags;
DB_LOCK_STAT *statp;
Db_timeout_t *timeoutp;

Const char *file_name = "mydb.db";
Dbenv_read = NULL;
Dbp = NULL;
Char * fruit = "Apple";
Int number = 15;

If ((ret = db_env_create (&dbenv_read, 0))> 0) (
Return (ret);
        }
If ((ret = dbenv_read->set_timeout (dbenv_read, 9000000, DB_SET_LOCK_TIMEOUT))> 0) (
Return (ret);
        }
If ((ret = dbenv_read->get_timeout (dbenv_read, timeoutp, DB_SET_LOCK_TIMEOUT)) !=0) (
Goto err;
        }
If ((ret = dbenv_read->open (dbenv_read that. " / "DB_CREATE|DB_INIT_MPOOL|DB_INIT_CDB, 0))> 0) (
Goto err;
        }

4003rd if ((ret = dbenv_read->lock_stat (dbenv_read, &statp, 0)) !=0) (
4003rd goto err;
//        }
If ((ret = db_create (&dbp, dbenv_read, 0))> 0) (
Goto err;
        }       
       
Open_flags = DB_CREATE;

Ret = dbp->open (dbp.
NULL.
File_name.
NULL.
DB_BTREE.
Open_flags.
                    0);         
If (ret> 0) (
Goto err;
            }
Init_DBT (&key, &data);
Key.data = fruit;
Key.size = strlen (fruit) + 1;
Data.data = &number;
Data.size = sizeof (int);

If ((ret = dbp->put (dbp, NULL, &key, &data, DB_NOOVERWRITE))> 0)
Printf ( "ERROR : %s\n" db_strerror (ret));

Init_DBT (&key, &data);

Key.data = fruit;
Key.size = strlen (fruit) + 1;
       
If ((ret = dbp->get (dbp, NULL, &key, &data, 0))> 0)
Printf ( "ERROR : %s\n" db_strerror (ret));

Printf ( "The number %d\n =" * (int*) (data.data));

Dbp->close (dbp, 0);
Dbenv_read->close (dbenv_read 0);
}
[/code]

Dbenv_read can we remove such packaging with the original api write it down. Can be edited.

Dbenv_read only name I would like to be irrelevant ah.
Dbenv wife is the original. Like the bars, how it played among themselves how.

It is irrelevant how it translated? Others.
Did you write can be re-edited version of this.


Get_timeout function that is now so bad, but it Zhushidiao, with the rear lock_stat () function can be read out of the timeout value.

I suggest you read a question of intelligence.
No code can be translated, without being given the compiler.
Maybe the problems do not lie with the bdb, but the packaging is wrong about you. Others could not diagnosis.



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com