From: Theodore Tso Date: Wed, 22 Sep 1993 02:31:48 +0000 (+0000) Subject: Changed to use the proper POSIX locking function if POSIX_FILE_LOCKS is X-Git-Tag: krb5-1.0-beta3~190 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=646e2ebb1617cedd2066ec3f5658f2a323e71bc5;p=krb5.git 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 --- 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 #include #include +#ifdef POSIX_FILE_LOCKS +#include +#endif #include #include @@ -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",