summaryrefslogtreecommitdiffstats
path: root/src/slave
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1993-09-22 02:31:48 +0000
committerTheodore Tso <tytso@mit.edu>1993-09-22 02:31:48 +0000
commit646e2ebb1617cedd2066ec3f5658f2a323e71bc5 (patch)
treed3d2bbe7ba1fdc714fd7d6802a1455a59376ba28 /src/slave
parent46bf914e3e87c0a3adaaa7ee06f839878619c1a7 (diff)
downloadkrb5-646e2ebb1617cedd2066ec3f5658f2a323e71bc5.tar.gz
krb5-646e2ebb1617cedd2066ec3f5658f2a323e71bc5.tar.xz
krb5-646e2ebb1617cedd2066ec3f5658f2a323e71bc5.zip
Changed to use the proper POSIX locking function if POSIX_FILE_LOCKS is
defined. (i.e., fcntl instead of lockf). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2648 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/slave')
-rw-r--r--src/slave/kprop.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/slave/kprop.c b/src/slave/kprop.c
index fbabf1a7b..c53f9deab 100644
--- a/src/slave/kprop.c
+++ b/src/slave/kprop.c
@@ -38,6 +38,9 @@ static char rcsid_kprop_c[] =
#include <krb5/los-proto.h>
#include <com_err.h>
#include <errno.h>
+#ifdef POSIX_FILE_LOCKS
+#include <fcntl.h>
+#endif
#include <stdio.h>
#include <ctype.h>
@@ -409,6 +412,9 @@ open_database(data_fn, size)
struct stat stbuf, stbuf_ok;
char *data_ok_fn;
static char ok[] = ".dump_ok";
+#ifdef POSIX_FILE_LOCKS
+ struct flock lock_arg;
+#endif
if ((fd = open(data_fn, O_RDONLY)) < 0) {
com_err(progname, errno, "while trying to open %s",
@@ -417,8 +423,11 @@ open_database(data_fn, size)
}
#ifdef POSIX_FILE_LOCKS
- if (lockf(fd, LOCK_SH | LOCK_NB, 0) < 0) {
- if (errno == EWOULDBLOCK || errno == EAGAIN)
+ lock_arg.l_whence = 0;
+ lock_arg.l_start = 0;
+ lock_arg.l_len = 0;
+ if (fcntl(fd, F_SETLK, &lock_arg) == -1) {
+ if (errno == EACCES || errno == EAGAIN)
com_err(progname, 0, "database locked");
else
com_err(progname, errno, "while trying to flock %s",