summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/util/util.h2
-rw-r--r--src/util/util_lock.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/src/util/util.h b/src/util/util.h
index 3cea997fb..f1524f3c5 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -556,7 +556,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 c2d7fac77..8db35a8cf 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;