- if (dbp->logfile_autoremove && db_env->log_archive(db_env, &logfiles, 0)) {
- LOG(log_error, logtype_cnid, "error getting list of stale logfiles: %s",
+ if (dbp->logfile_autoremove) {
+ if (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);
+ }
+
+#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7)
+ if ((ret = db_env->log_set_config(db_env, DB_LOG_AUTO_REMOVE, 1))) {
+ LOG(log_error, logtype_cnid, "error setting DB_LOG_AUTO_REMOVE flag: %s",