err = flock_acquire(&add->tables_list_lock, st->list_file,
st->opts.lock_timeout_ms);
- if (err < 0) {
- if (errno == EEXIST) {
- err = REFTABLE_LOCK_ERROR;
- } else {
- err = REFTABLE_IO_ERROR;
- }
+ if (err < 0)
goto done;
- }
+
if (st->opts.default_permissions) {
if (chmod(add->tables_list_lock.path,
st->opts.default_permissions) < 0) {
* which are part of the user-specified range.
*/
err = flock_acquire(&tables_list_lock, st->list_file, st->opts.lock_timeout_ms);
- if (err < 0) {
- if (errno == EEXIST)
- err = REFTABLE_LOCK_ERROR;
- else
- err = REFTABLE_IO_ERROR;
+ if (err < 0)
goto done;
- }
/*
* Check whether the stack is up-to-date. We unfortunately cannot
* tables, otherwise there would be nothing to compact.
* In that case, we return a lock error to our caller.
*/
- if (errno == EEXIST && last - (i - 1) >= 2 &&
+ if (err == REFTABLE_LOCK_ERROR && last - (i - 1) >= 2 &&
flags & STACK_COMPACT_RANGE_BEST_EFFORT) {
err = 0;
/*
*/
first = (i - 1) + 1;
break;
- } else if (errno == EEXIST) {
- err = REFTABLE_LOCK_ERROR;
- goto done;
- } else {
- err = REFTABLE_IO_ERROR;
- goto done;
}
+
+ goto done;
}
/*
* of tables.
*/
err = flock_close(&table_locks[nlocks++]);
- if (err < 0) {
- err = REFTABLE_IO_ERROR;
+ if (err < 0)
goto done;
- }
}
/*
* the new table.
*/
err = flock_acquire(&tables_list_lock, st->list_file, st->opts.lock_timeout_ms);
- if (err < 0) {
- if (errno == EEXIST)
- err = REFTABLE_LOCK_ERROR;
- else
- err = REFTABLE_IO_ERROR;
+ if (err < 0)
goto done;
- }
if (st->opts.default_permissions) {
if (chmod(tables_list_lock.path,
* to acquire the lock. If `timeout_ms` is 0 we don't wait, if it is negative
* we block indefinitely.
*
- * Retrun 0 on success, a reftable error code on error.
+ * Retrun 0 on success, a reftable error code on error. Specifically,
+ * `REFTABLE_LOCK_ERROR` should be returned in case the target path is already
+ * locked.
*/
int flock_acquire(struct reftable_flock *l, const char *target_path,
long timeout_ms);