summaryrefslogtreecommitdiff
path: root/src/responder/nss
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2012-10-26 17:36:51 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-11-06 12:29:28 +0100
commit33cbb789ff71be5dccbb4a0acd68814b0d53da34 (patch)
treeb2024faaf3664ef727e927407b554d87a8c7df41 /src/responder/nss
parent0a55f903a1da319338fdcf147efa01ed22f9710d (diff)
downloadsssd-33cbb789ff71be5dccbb4a0acd68814b0d53da34.tar.gz
sssd-33cbb789ff71be5dccbb4a0acd68814b0d53da34.tar.bz2
sssd-33cbb789ff71be5dccbb4a0acd68814b0d53da34.zip
sss_cache: Remove fastcache even if sssd is not running.
https://fedorahosted.org/sssd/ticket/1584
Diffstat (limited to 'src/responder/nss')
-rw-r--r--src/responder/nss/nsssrv_mmap_cache.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c
index f4025647..524aa47c 100644
--- a/src/responder/nss/nsssrv_mmap_cache.c
+++ b/src/responder/nss/nsssrv_mmap_cache.c
@@ -537,14 +537,21 @@ static errno_t sss_mc_create_file(struct sss_mc_ctx *mc_ctx)
mode_t old_mask;
int ofd;
int ret;
+ useconds_t t = 50000;
+ int retries = 3;
ofd = open(mc_ctx->file, O_RDWR);
if (ofd != -1) {
+ ret = sss_br_lock_file(ofd, 0, 1, retries, t);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Failed to lock file %s.\n", mc_ctx->file));
+ }
ret = sss_mc_set_recycled(ofd);
if (ret) {
- DEBUG(SSSDBG_TRACE_FUNC, ("Failed to mark mmap file %s as"
- " recycled: %d(%s)\n",
- mc_ctx->file, ret, strerror(ret)));
+ DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to mark mmap file %s as"
+ " recycled: %d(%s)\n",
+ mc_ctx->file, ret, strerror(ret)));
}
close(ofd);
@@ -568,11 +575,24 @@ static errno_t sss_mc_create_file(struct sss_mc_ctx *mc_ctx)
ret = errno;
DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to open mmap file %s: %d(%s)\n",
mc_ctx->file, ret, strerror(ret)));
+ goto done;
+ }
+
+ ret = sss_br_lock_file(mc_ctx->fd, 0, 1, retries, t);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Failed to lock file %s.\n", mc_ctx->file));
+ goto done;
}
+done:
/* reset mask back */
umask(old_mask);
+ if (ret) {
+ close(mc_ctx->fd);
+ }
+
return ret;
}