diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2007-04-14 22:20:10 +0000 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2007-04-14 22:20:10 +0000 |
commit | 8ca43646a6c87d00d5b2cb74cebf65a8d0ea5e8e (patch) | |
tree | 724ddc9ab6cb3a362051fe1e081b3ccdcd7c0d5c /src/rccdb4.c | |
parent | b91203daf1a2b5865bfd284821c0c0b103f5b8e7 (diff) | |
download | librcc-8ca43646a6c87d00d5b2cb74cebf65a8d0ea5e8e.tar.gz librcc-8ca43646a6c87d00d5b2cb74cebf65a8d0ea5e8e.tar.bz2 librcc-8ca43646a6c87d00d5b2cb74cebf65a8d0ea5e8e.tar.xz librcc-8ca43646a6c87d00d5b2cb74cebf65a8d0ea5e8e.zip |
DB4 & Postponed processing
- New DB4 database type
- Postponed processing in external module
+ User may allow external module to finish required processing before
termination. This could be useful for translation services while using
console applications (if network connection is slow, the external will
never finish translation before program termination)
- SKIP_PARRENT options are renamed to SKIP_PARENT
Diffstat (limited to 'src/rccdb4.c')
-rw-r--r-- | src/rccdb4.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/rccdb4.c b/src/rccdb4.c index a4e0976..1eb5d44 100644 --- a/src/rccdb4.c +++ b/src/rccdb4.c @@ -5,6 +5,7 @@ #include "../config.h" #include "internal.h" +#include "rcchome.h" #include "rccdb4.h" #define DATABASE "autolearn.db" @@ -15,21 +16,36 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { #ifdef HAVE_DB_H DB_ENV *dbe; DB *db; - + +# if 0 char stmp[160]; +# endif err = db_env_create(&dbe, 0); if (err) return NULL; +# if 1 + dbe->set_flags(dbe, DB_LOG_AUTOREMOVE, 1); + dbe->set_lg_max(dbe, 131072); + + err = rccLock(); + if (!err) { + err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_TXN|DB_USE_ENVIRON|DB_INIT_LOCK|DB_INIT_MPOOL|DB_RECOVER, 00644); + rccUnLock(); + } +# else err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 00644); if (err == DB_VERSION_MISMATCH) { - if (!rccLock()) { err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_USE_ENVIRON|DB_PRIVATE|DB_RECOVER, 0); + dbe->close(dbe, 0); + dbe->remove(dbe, dbpath, 0); rccUnLock(); - } else err = -1; - - dbe->close(dbe, 0); + } else { + err = -1; + dbe->close(dbe, 0); + } + if (err) return NULL; if (strlen(dbpath)<128) { @@ -43,8 +59,10 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 00644); } - +# endif + if (err) { +// fprintf(stderr, "BerkelyDB initialization failed: %i (%s)\n", err, db_strerror(err)); dbe->close(dbe, 0); return NULL; } @@ -55,6 +73,7 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { return NULL; } + err = db->open(db, NULL, DATABASE, NULL, DB_BTREE, DB_CREATE, 0); if (err) { db->close(db, 0); @@ -71,7 +90,7 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { #endif /* HAVE_DB_H */ return NULL; } - + #ifdef HAVE_DB_H ctx->db = db; ctx->dbe = dbe; |