Licensing Information

Open Source Used In Cisco FXOS 1.1(3) 855
fl.l_type = set==LOCK_SET?rw_type:F_UNLCK;
fl.l_whence = SEEK_SET;
fl.l_start = offset;
fl.l_len = 1;
fl.l_pid = 0;
if (fcntl(tdb->fd, lck_type, &fl) != 0) {
#if TDB_DEBUG
if (lck_type == F_SETLKW) {
printf("lock %d failed at %d (%s)\n",
 set, offset, strerror(errno));
}
#endif
tdb->ecode = TDB_ERR_LOCK;
return -1;
}
return 0;
#endif
}
/* lock a list in the database. list -1 is the alloc list */
static int tdb_lock(TDB_CONTEXT *tdb, int list)
{
if (list < -1 || list >= (int)tdb->header.hash_size) {
#if TDB_DEBUG
printf("bad list %d\n", list);
#endif
return -1;
}
if (tdb->locked[list+1] == 0) {
if (tdb_brlock(tdb, LIST_LOCK_BASE + 4*list, LOCK_SET,
 F_WRLCK, F_SETLKW) != 0) {
return -1;
}
}
tdb->locked[list+1]++;
return 0;
}
/* unlock the database. */
static int tdb_unlock(TDB_CONTEXT *tdb, int list)
{
if (list < -1 || list >= (int)tdb->header.hash_size) {
#if TDB_DEBUG
printf("bad unlock list %d\n", list);
#endif
return -1;
}