Licensing Information

Open Source Used In Cisco FXOS 1.1(4) 977
if (tdb->name) free(tdb->name);
if (tdb->fd != -1) close(tdb->fd);
if (tdb->locked) free(tdb->locked);
if (tdb->map_ptr) {
if (tdb->fd != -1) {
munmap(tdb->map_ptr, tdb->map_size);
} else {
free(tdb->map_ptr);
}
}
memset(tdb, 0, sizeof(*tdb));
free(tdb);
return 0;
}
/* lock the database. If we already have it locked then don't do anything */
int tdb_writelock(TDB_CONTEXT *tdb)
{
if (tdb == NULL) {
#ifdef TDB_DEBUG
printf("tdb_writelock() called with null context\n");
#endif
return -1;
}
return tdb_lock(tdb, -1);
}
/* unlock the database. */
int tdb_writeunlock(TDB_CONTEXT *tdb)
{
if (tdb == NULL) {
#ifdef TDB_DEBUG
printf("tdb_writeunlock() called with null context\n");
#endif
return -1;
}
return tdb_unlock(tdb, -1);
}
/* lock one hash chain. This is meant to be used to reduce locking
contention - it cannot guarantee how many records will be locked */
int tdb_lockchain(TDB_CONTEXT *tdb, TDB_DATA key)
{