diff options
author | Michal Zidek <mzidek@redhat.com> | 2012-10-26 17:36:51 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-11-06 21:24:18 +0100 |
commit | 5638b9f27d7952e87b522e1a9330316a94139b9c (patch) | |
tree | 7e6a782ad4f8a60461116c7cd1af19bba1b4ca4a /src/responder/nss/nsssrv_mmap_cache.c | |
parent | 28321c65b94f29956792a9fc7eaab60d3a4b5f21 (diff) | |
download | sssd-5638b9f27d7952e87b522e1a9330316a94139b9c.tar.gz sssd-5638b9f27d7952e87b522e1a9330316a94139b9c.tar.xz sssd-5638b9f27d7952e87b522e1a9330316a94139b9c.zip |
sss_cache: Remove fastcache even if sssd is not running.
https://fedorahosted.org/sssd/ticket/1584
Diffstat (limited to 'src/responder/nss/nsssrv_mmap_cache.c')
-rw-r--r-- | src/responder/nss/nsssrv_mmap_cache.c | 26 |
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 f40256472..524aa47c3 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; } |