/*
- * $Id: cnid_update.c,v 1.12.2.1 2001-12-03 05:05:51 jmarcus Exp $
+ * $Id: cnid_update.c,v 1.12.2.4 2002-02-09 20:29:02 jmarcus Exp $
*/
#ifdef HAVE_CONFIG_H
retry:
if ((rc = txn_begin(db->dbenv, NULL, &tid, 0))) {
- syslog(LOG_ERR, "cnid_update: Failed to begin transaction: %s",
- db_strerror(rc));
+ syslog(LOG_ERR, "cnid_update: Failed to begin transaction: %s", db_strerror(rc));
return rc;
}
switch (rc) {
case DB_LOCK_DEADLOCK:
goto retry;
+ case DB_NOTFOUND:
+ /* Silently fail here. We're allowed to do this since this CNID
+ * might have been deleted out from under us, or someone has
+ * called cnid_lookup then cnid_update (which is redundant). */
+ return 0;
default:
goto update_err;
}
data.data = make_cnid_data(st, did, name, len);
data.size = CNID_HEADER_LEN + len + 1;
+ /* Update the old CNID with the new info. */
+ key.data = (cnid_t *) &id;
+ key.size = sizeof(id);
+ if ((rc = db->db_cnid->put(db->db_cnid, tid, &key, &data, 0))) {
+ txn_abort(tid);
+ switch (rc) {
+ case DB_LOCK_DEADLOCK:
+ goto retry;
+ default:
+ goto update_err;
+ }
+ }
+
/* Put in a new dev/ino mapping. */
key.data = data.data;
key.size = CNID_DEVINO_LEN;
}
}
- /* Update the old CNID with the new info. */
- key.data = (cnid_t *) &id;
- key.size = sizeof(id);
- if ((rc = db->db_cnid->put(db->db_cnid, tid, &key, &data, 0))) {
- txn_abort(tid);
- switch (rc) {
- case DB_LOCK_DEADLOCK:
- goto retry;
- default:
- goto update_err;
- }
- }
return txn_commit(tid, 0);
update_err:
syslog(LOG_ERR, "cnid_update: Unable to update CNID %u: %s",
- ntohl(id), db_strerror(rc));
+ ntohl(id), db_strerror(rc));
return -1;
}
#endif /* CNID_DB */