counter = &(self->lock.shared);
/* Check for overflow */
- g_assert_cmpuint (*counter, <, G_MAXUINT);
+ if (*counter == G_MAXUINT)
+ g_error ("Repo lock %s counter would overflow", lock_state_name (next_state));
if (info.state == LOCK_EX || info.state == next_state)
{
int flags = blocking ? 0 : LOCK_NB;
g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&self->lock.mutex);
- g_return_val_if_fail (self->lock.fd != -1, FALSE);
+ if (self->lock.fd == -1)
+ g_error ("Cannot pop repo never locked repo lock");
OstreeRepoLockInfo info;
repo_lock_info (self, locker, &info);
- g_return_val_if_fail (info.len > 0, FALSE);
g_debug ("Pop lock: state=%s, depth=%u", info.name, info.len);
+ if (info.len == 0 || info.state == LOCK_UN)
+ g_error ("Cannot pop already unlocked repo lock");
+
int state_to_drop;
guint *counter;
if (lock_type == OSTREE_REPO_LOCK_EXCLUSIVE)
}
/* Make sure caller specified a valid type to release */
- g_assert_cmpuint (*counter, >, 0);
+ if (*counter == 0)
+ g_error ("Repo %s lock pop requested, but none have been taken",
+ lock_state_name (state_to_drop));
int next_state;
if (info.len == 1)
else
{
/* We should never drop from shared to exclusive */
- g_return_val_if_fail (next_state == LOCK_SH, FALSE);
+ g_assert (next_state == LOCK_SH);
g_debug ("Returning lock state to shared");
if (!do_repo_lock (self->lock.fd, next_state | flags))
return glnx_throw_errno_prefix (error,