2 * $Id: cnid_close.c,v 1.6 2001-08-31 14:58:48 rufustfirefly Exp $
7 #endif /* HAVE_CONFIG_H */
12 #endif /* HAVE_UNISTD_H */
15 #endif /* HAVE_FCNTL_H */
22 #include <atalk/cnid.h>
24 #include "cnid_private.h"
26 void cnid_close(void *CNID)
33 /* flush the transaction log and delete the log file if we can. */
34 if ((db->lockfd > -1) && ((db->flags & CNIDFLAG_DB_RO) == 0)) {
37 lock.l_type = F_WRLCK;
38 lock.l_whence = SEEK_SET;
39 lock.l_start = lock.l_len = 0;
40 if (fcntl(db->lockfd, F_SETLK, &lock) == 0) {
43 errno = txn_checkpoint(db->dbenv, 0, 0, 0);
44 while (errno == DB_INCOMPLETE)
45 errno = txn_checkpoint(db->dbenv, 0, 0, 0);
47 /* we've checkpointed, so clean up the log files.
48 * NOTE: any real problems will make log_archive return an error. */
49 chdir(db->dbenv->db_log_dir ? db->dbenv->db_log_dir : db->dbenv->db_home);
50 if (!log_archive(db->dbenv, &first, DB_ARCH_LOG, NULL)) {
53 if (truncate(*list, 0) < 0)
54 syslog(LOG_INFO, "cnid_close: failed to truncate %s: %s",
55 *list, strerror(errno));
63 db->db_didname->close(db->db_didname, 0);
64 db->db_devino->close(db->db_devino, 0);
65 db->db_cnid->close(db->db_cnid, 0);
66 db->dbenv->close(db->dbenv, 0);
69 close(db->lockfd); /* this will also close any lock we have. */