X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fcnid_dbd%2Fdbif.c;h=d7f19bd9a933f6512c2040d1cd55e84087f732e5;hb=7bd0ab8692a994665b52d5680359e64866526fc1;hp=b1b3599a0abb7542540d78ced4c4187ebb25f5b7;hpb=815d557e167e76015934397dffbfa869180dcdbc;p=netatalk.git diff --git a/etc/cnid_dbd/dbif.c b/etc/cnid_dbd/dbif.c index b1b3599a..d7f19bd9 100644 --- a/etc/cnid_dbd/dbif.c +++ b/etc/cnid_dbd/dbif.c @@ -1,5 +1,5 @@ /* - * $Id: dbif.c,v 1.15 2009-10-13 22:55:37 didg Exp $ + * $Id: dbif.c,v 1.19 2009-12-21 06:41:09 franklahm Exp $ * * Copyright (C) Joerg Lenneis 2003 * Copyright (C) Frank Lahm 2009 @@ -247,10 +247,29 @@ int dbif_env_open(DBD *dbd, struct db_param *dbp, uint32_t dbenv_oflags) return -1; } if (logfiles != NULL) { + /* Remember cwd */ + if ((cwd = open(".", O_RDONLY)) < 0) { + LOG(log_error, logtype_cnid, "error opening cwd: %s", strerror(errno)); + goto logfiles_done; + } + /* chdir to db_envhome */ + if ((chdir(dbd->db_envhome)) != 0) { + LOG(log_error, logtype_cnid, "error chdiring to db_env '%s': %s", dbd->db_envhome, strerror(errno)); + goto logfiles_done; + } + for (file = logfiles; *file != NULL; file++) { if (unlink(*file) < 0) LOG(log_warning, logtype_cnid, "Error removing stale logfile %s: %s", *file, strerror(errno)); } + + /* chdir back */ + if ((fchdir(cwd)) != 0) { + LOG(log_error, logtype_cnid, "error chdiring back: %s", strerror(errno)); + return -1; + } + + logfiles_done: free(logfiles); } @@ -277,7 +296,7 @@ int dbif_env_open(DBD *dbd, struct db_param *dbp, uint32_t dbenv_oflags) } /* --------------- */ -int dbif_open(DBD *dbd, struct db_param *dbp _U_, int reindex) +int dbif_open(DBD *dbd, struct db_param *dbp, int reindex) { int ret, i, cwd; u_int32_t count; @@ -299,7 +318,7 @@ int dbif_open(DBD *dbd, struct db_param *dbp _U_, int reindex) } if ((stat(dbd->db_filename, &st)) == 0) { - LOG(log_debug, logtype_cnid, "See if we can upgrade the CNID database"); + LOG(log_debug, logtype_cnid, "See if we can upgrade the CNID database..."); if ((ret = db_create(&upgrade_db, dbd->db_env, 0))) { LOG(log_error, logtype_cnid, "error creating handle for database: %s", db_strerror(ret)); return -1; @@ -316,6 +335,7 @@ int dbif_open(DBD *dbd, struct db_param *dbp _U_, int reindex) LOG(log_error, logtype_cnid, "error forcing checkpoint: %s", db_strerror(ret)); return -1; } + LOG(log_debug, logtype_cnid, "Finished CNID database upgrade check"); } if ((fchdir(cwd)) != 0) { @@ -341,6 +361,18 @@ int dbif_open(DBD *dbd, struct db_param *dbp _U_, int reindex) } } + if ( ! dbd->db_env) { /* In memory db */ + if ((ret = dbd->db_table[i].db->set_cachesize(dbd->db_table[i].db, + 0, + dbp->cachesize, + 4)) /* split in 4 memory chunks */ + < 0) { + LOG(log_error, logtype_cnid, "error setting cachesize %u KB for database %s: %s", + dbp->cachesize / 1024, dbd->db_table[i].name, db_strerror(ret)); + return -1; + } + } + if (dbd->db_table[i].db->open(dbd->db_table[i].db, dbd->db_txn, dbd->db_filename, @@ -399,7 +431,7 @@ int dbif_open(DBD *dbd, struct db_param *dbp _U_, int reindex) } /* ------------------------ */ -int dbif_closedb(DBD *dbd) +static int dbif_closedb(DBD *dbd) { int i; int ret;