call);
}
-/* If we fork, we no longer really own locks: preserves errno */
+/* If we fork, we no longer really own locks. */
static bool check_lock_pid(struct tdb_context *tdb,
const char *call, bool log)
{
static enum TDB_ERROR tdb_brunlock(struct tdb_context *tdb,
int rw_type, tdb_off_t offset, size_t len)
{
- int ret;
-
if (tdb->flags & TDB_NOLOCK) {
return TDB_SUCCESS;
}
- ret = unlock(tdb, rw_type, offset, len);
+ if (!check_lock_pid(tdb, "tdb_brunlock", true))
+ return TDB_ERR_LOCK;
- /* If we fail, *then* we verify that we owned the lock. If not, ok. */
- if (ret == -1 && check_lock_pid(tdb, "tdb_brunlock", false)) {
+ if (unlock(tdb, rw_type, offset, len) == -1) {
return tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR,
"tdb_brunlock failed (fd=%d) at offset %zu"
" rw_type=%d len=%zu: %s",
return TDB_SUCCESS;
}
+#if 0
if (tdb->file->num_lockrecs
&& offset >= TDB_HASH_LOCK_START
&& offset < TDB_HASH_LOCK_START + TDB_HASH_LOCK_RANGE) {
return tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR,
"tdb_nest_lock: already have a hash lock?");
}
+#endif
new_lck = (struct tdb_lock *)realloc(
tdb->file->lockrecs,
{
unsigned int i;
+ /* We don't want to warn: they're allowed to close tdb after fork. */
+ if (!check_lock_pid(tdb, "tdb_close", false))
+ return;
+
while (tdb->file->allrecord_lock.count
&& tdb->file->allrecord_lock.owner == tdb) {
tdb_allrecord_unlock(tdb, tdb->file->allrecord_lock.ltype);