2 * $Id: cnid_close.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $
7 #endif /* HAVE_CONFIG_H */
11 #endif /* HAVE_UNISTD_H */
14 #endif /* HAVE_FCNTL_H */
19 #include <atalk/cnid.h>
21 #include "cnid_private.h"
23 void cnid_close(void *CNID)
30 /* flush the transaction log and delete the log file if we can. */
31 if ((db->lockfd > -1) && ((db->flags & CNIDFLAG_DB_RO) == 0)) {
34 lock.l_type = F_WRLCK;
35 lock.l_whence = SEEK_SET;
36 lock.l_start = lock.l_len = 0;
37 if (fcntl(db->lockfd, F_SETLK, &lock) == 0) {
41 txnp = db->dbenv.tx_info;
42 errno = txn_checkpoint(txnp, 0, 0);
43 while (errno == DB_INCOMPLETE)
44 errno = txn_checkpoint(txnp, 0, 0);
46 /* we've checkpointed, so clean up the log files.
47 * NOTE: any real problems will make log_archive return an error. */
48 chdir(db->dbenv.db_log_dir ? db->dbenv.db_log_dir : db->dbenv.db_home);
49 if (!log_archive(db->dbenv.lg_info, &first, DB_ARCH_LOG, NULL)) {
52 if (truncate(*list, 0) < 0)
53 syslog(LOG_INFO, "cnid_close: failed to truncate %s: %m", *list);
61 db->db_didname->close(db->db_didname, 0);
62 db->db_devino->close(db->db_devino, 0);
63 db->db_cnid->close(db->db_cnid, 0);
64 db_appexit(&db->dbenv);
66 close(db->lockfd); /* this will also close any lock we have. */
67 ad_close(&db->rootinfo, ADFLAGS_HF);