/*
- * $Id: db_param.c,v 1.1.4.3 2004-01-09 21:05:50 lenneis Exp $
+ * $Id: db_param.c,v 1.1.4.4 2004-04-29 18:09:14 lenneis Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
#define DB_PARAM_FN "db_param"
#define MAXKEYLEN 64
-#define DEFAULT_BACKLOG 20
+#define DEFAULT_LOGFILE_AUTOREMOVE 0
#define DEFAULT_CACHESIZE 1024 * 4
#define DEFAULT_NOSYNC 0
#define DEFAULT_FLUSH_FREQUENCY 100
static void default_params(struct db_param *dbp, char *dir)
{
- dbp->backlog = DEFAULT_BACKLOG;
+ dbp->logfile_autoremove = DEFAULT_LOGFILE_AUTOREMOVE;
dbp->cachesize = DEFAULT_CACHESIZE;
dbp->nosync = DEFAULT_NOSYNC;
dbp->flush_frequency = DEFAULT_FLUSH_FREQUENCY;
break;
}
- if (! strcmp(key, "backlog"))
- params.backlog = parse_int(val);
+ if (! strcmp(key, "logfile_autoremove"))
+ params.logfile_autoremove = parse_int(val);
else if (! strcmp(key, "cachesize"))
params.cachesize = parse_int(val);
else if (! strcmp(key, "nosync"))
/*
- * $Id: db_param.h,v 1.1.4.3 2004-01-09 21:05:50 lenneis Exp $
+ * $Id: db_param.h,v 1.1.4.4 2004-04-29 18:09:16 lenneis Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
struct db_param {
- int backlog;
+ int logfile_autoremove;
int cachesize;
int nosync;
int flush_frequency;
/*
- * $Id: dbif.c,v 1.1.4.14 2004-02-07 18:45:46 didg Exp $
+ * $Id: dbif.c,v 1.1.4.15 2004-04-29 18:09:16 lenneis Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
int dbif_env_init(struct db_param *dbp)
{
int ret;
+#ifdef CNID_BACKEND_DBD_TXN
+ char **logfiles = NULL;
+ char **file;
+#endif
/* Refuse to do anything if this is an old version of the CNID database */
if (upgrade_required()) {
db_strerror(ret));
db_env->close(db_env, 0);
db_env = NULL;
- return -1;
+ return -1;
+ }
+ if (dbp->logfile_autoremove && db_env->log_archive(db_env, &logfiles, 0)) {
+ LOG(log_error, logtype_cnid, "error getting list of stale logfiles: %s",
+ db_strerror(ret));
+ db_env->close(db_env, 0);
+ db_env = NULL;
+ return -1;
+ }
+ if (logfiles != NULL) {
+ for (file = logfiles; *file != NULL; file++) {
+ if (unlink(*file) < 0)
+ LOG(log_warning, logtype_cnid, "Error removing stale logfile %s: %s", *file, strerror(errno));
+ }
+ free(logfiles);
}
#endif
return 0;