diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util/util.h | 2 | ||||
-rw-r--r-- | src/util/util_lock.c | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/util/util.h b/src/util/util.h index d9315aef..b6ecfc2c 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -561,7 +561,7 @@ struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx, /* from util_lock.c */ errno_t sss_br_lock_file(int fd, size_t start, size_t len, - int retries, useconds_t wait); + int num_tries, useconds_t wait); /* Endianness-compatibility for systems running older versions of glibc */ diff --git a/src/util/util_lock.c b/src/util/util_lock.c index c2d7fac7..8db35a8c 100644 --- a/src/util/util_lock.c +++ b/src/util/util_lock.c @@ -29,19 +29,23 @@ #include "util/util.h" errno_t sss_br_lock_file(int fd, size_t start, size_t len, - int retries, useconds_t wait) + int num_tries, useconds_t wait) { int ret; struct flock lock; int retries_left; + if (num_tries <= 0) { + return EINVAL; + } + lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; lock.l_start = start; lock.l_len = len; lock.l_pid = 0; - for (retries_left = retries; retries_left > 0; retries_left--) { + for (retries_left = num_tries; retries_left > 0; retries_left--) { ret = fcntl(fd, F_SETLK, &lock); if (ret == -1) { ret = errno; |