- syslog(LOG_ERR, "cnid_add: Unable to lookup rootinfo: %s",
- db_strerror(rc));
- goto cleanup_err;
- }
-
-
- if (0) {
-retry:
- t.tv_usec = rand() % 1000000;
-#ifdef DEBUG
- syslog(LOG_INFO, "cnid_add: Hitting MAX_ABORTS, sleeping");
-#endif
- (void)select(0, NULL, NULL, NULL, &t);
- }
- if ((rc = txn_begin(db->dbenv, NULL, &tid, 0)) != 0) {
- syslog(LOG_ERR, "cnid_add: Failed to begin transaction: %s",
- db_strerror(rc));
- goto cleanup_err;
- }
-
- /* Search for a new id. We keep the first id around to check for
- * wrap-around. NOTE: I do it this way so that we can go back and
- * fill in holes. */
- save = id = ntohl(hint);
- while ((rc = add_cnid(db, tid, &key, &data)) != 0) {
- /* Don't use any special CNIDs. */
- if (++id < CNID_START) {
- id = CNID_START;
- }
- if (rc == DB_LOCK_DEADLOCK) {
- if ((rc = txn_abort(tid)) != 0) {
- syslog(LOG_ERR, "cnid_add: txn_abort: %s", db_strerror(rc));
- goto cleanup_err;
- }
- goto retry;
- }
-
- if ((rc != DB_KEYEXIST) || (save == id)) {
- syslog(LOG_ERR, "cnid_add: Unable to add CNID %u: %s",
- ntohl(hint), db_strerror(rc));
- goto cleanup_abort;
- }
- hint = htonl(id);