struct server_id *blocker)
{
TDB_DATA data, userdata;
- size_t i, num_locks, my_lock;
+ size_t i, num_locks;
struct g_lock_rec *locks, *tmp;
NTSTATUS status;
bool modified = false;
return status;
}
- my_lock = num_locks; /* doesn't exist yet */
-
if ((type == G_LOCK_READ) && (num_locks > 0)) {
/*
* Read locks can stay around forever if the process
status = NT_STATUS_WAS_LOCKED;
goto done;
}
- my_lock = i;
+ /*
+ * Remove "our" lock entry. Re-add it later
+ * with our new lock type.
+ */
+ locks[i] = locks[num_locks-1];
+ num_locks -= 1;
continue;
}
}
}
- if (my_lock >= num_locks) {
- tmp = talloc_realloc(talloc_tos(), locks, struct g_lock_rec,
- num_locks+1);
- if (tmp == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
- locks = tmp;
- my_lock = num_locks;
- num_locks += 1;
+ tmp = talloc_realloc(talloc_tos(), locks, struct g_lock_rec,
+ num_locks+1);
+ if (tmp == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
}
+ locks = tmp;
+
+ locks[num_locks] = (struct g_lock_rec) {
+ .pid = self, .lock_type = type
+ };
+ num_locks +=1 ;
- locks[my_lock] = (struct g_lock_rec){ .pid = self, .lock_type = type };
modified = true;
status = NT_STATUS_OK;