/*
- * $Id: cnid_close.c,v 1.17 2001-12-13 15:15:05 jmarcus Exp $
+ * $Id: cnid_close.c,v 1.18 2001-12-14 03:10:37 jmarcus Exp $
*/
#ifdef HAVE_CONFIG_H
lock.l_start = lock.l_len = 0;
if (fcntl(db->lockfd, F_SETLK, &lock) == 0) {
char **list, **first;
+ int cfd = -1;
- /* Checkpoint the databases until we can checkpoint no
- * more. */
- rc = txn_checkpoint(db->dbenv, 0, 0, 0);
- while (rc == DB_INCOMPLETE) {
+ if ((cfd = open(db->close_file, O_RDWR | O_CREAT, 0666)) > -1) {
+
+ /* Checkpoint the databases until we can checkpoint no
+ * more. */
rc = txn_checkpoint(db->dbenv, 0, 0, 0);
- }
+ while (rc == DB_INCOMPLETE) {
+ rc = txn_checkpoint(db->dbenv, 0, 0, 0);
+ }
#if DB_VERSION_MINOR > 2
- if ((rc = log_archive(db->dbenv, &list, DB_ARCH_LOG | DB_ARCH_ABS)) != 0) {
+ if ((rc = log_archive(db->dbenv, &list, DB_ARCH_LOG | DB_ARCH_ABS)) != 0) {
#else /* DB_VERSION_MINOR < 2 */
- if ((rc = log_archive(db->dbenv, &list, DB_ARCH_LOG | DB_ARCH_ABS, NULL)) != 0) {
+ if ((rc = log_archive(db->dbenv, &list, DB_ARCH_LOG | DB_ARCH_ABS, NULL)) != 0) {
#endif /* DB_VERSION_MINOR */
- syslog(LOG_ERR, "cnid_close: Unable to archive logfiles: %s",
- db_strerror(rc));
- }
+ syslog(LOG_ERR, "cnid_close: Unable to archive logfiles: %s",
+ db_strerror(rc));
+ }
- if (list != NULL) {
- for (first = list; *list != NULL; ++list) {
- if ((rc = remove(*list)) != 0) {
+ if (list != NULL) {
+ for (first = list; *list != NULL; ++list) {
+ if ((rc = remove(*list)) != 0) {
#ifdef DEBUG
- syslog(LOG_INFO, "cnid_close: failed to remove %s: %s",
- *list, strerror(rc));
+ syslog(LOG_INFO, "cnid_close: failed to remove %s: %s",
+ *list, strerror(rc));
#endif
+ }
}
+ free(first);
}
- free(first);
+ (void)remove(db->close_file);
+ close(cfd);
+ }
+ else {
+ syslog(LOG_ERR, "cnid_close: Failed to open database closing lock file: %s", strerror(errno));
}
}
}