From 14747af538f3acf8359b41f1a669d894238d3525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Tue, 31 May 2005 21:48:57 +0000 Subject: [PATCH] (_krb5_xunlock): catch the error and turn it into something sensable git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15325 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/fcache.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/krb5/fcache.c b/lib/krb5/fcache.c index e61e745ed..466f18ef9 100644 --- a/lib/krb5/fcache.c +++ b/lib/krb5/fcache.c @@ -105,18 +105,33 @@ _krb5_xlock(krb5_context context, int fd, krb5_boolean exclusive, } int -_krb5_xunlock(int fd) +_krb5_xunlock(krb5_context context, int fd) { + int ret; #ifdef HAVE_FCNTL_LOCK struct flock l; l.l_start = 0; l.l_len = 0; l.l_type = F_UNLCK; l.l_whence = SEEK_SET; - return fcntl(fd, F_SETLKW, &l); + ret = fcntl(fd, F_SETLKW, &l); #else - return flock(fd, LOCK_UN); + ret = flock(fd, LOCK_UN); #endif + if (ret < 0) + ret = errno; + switch (ret) { + case 0: + break; + case EINVAL: /* filesystem doesn't support locking, let the user have it */ + ret = 0; + break; + default: + krb5_set_error_string(context, + "Failed to unlock file: %s", strerror(ret)); + break; + } + return ret; } static krb5_error_code @@ -129,7 +144,7 @@ fcc_lock(krb5_context context, krb5_ccache id, static krb5_error_code fcc_unlock(krb5_context context, int fd) { - return _krb5_xunlock(fd); + return _krb5_xunlock(context, fd); } static krb5_error_code