diff options
author | Michal Zidek <mzidek@redhat.com> | 2012-09-11 18:44:52 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-09-24 13:09:53 +0200 |
commit | 99c99e557020775714f028b28a147edda290c783 (patch) | |
tree | 7364f53b4c921aacf7f81da4864f27d3c9d25c62 /src/responder/nss/nsssrv_mmap_cache.c | |
parent | 7c2e91ac48b20e6699d5c98c9912ea6427453c95 (diff) | |
download | sssd-99c99e557020775714f028b28a147edda290c783.tar.gz sssd-99c99e557020775714f028b28a147edda290c783.tar.bz2 sssd-99c99e557020775714f028b28a147edda290c783.zip |
sss_cache tool invalidates records in memory cache.
Diffstat (limited to 'src/responder/nss/nsssrv_mmap_cache.c')
-rw-r--r-- | src/responder/nss/nsssrv_mmap_cache.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c index 07498a9b..f4025647 100644 --- a/src/responder/nss/nsssrv_mmap_cache.c +++ b/src/responder/nss/nsssrv_mmap_cache.c @@ -725,3 +725,49 @@ done: return ret; } +errno_t sss_mmap_cache_reinit(TALLOC_CTX *mem_ctx, size_t n_elem, + time_t timeout, struct sss_mc_ctx **mc_ctx) +{ + errno_t ret; + TALLOC_CTX* tmp_ctx = NULL; + char *name; + enum sss_mc_type type; + + if (mc_ctx == NULL || (*mc_ctx) == NULL) { + DEBUG(SSSDBG_CRIT_FAILURE, + ("Unable to re-init unitialized memory cache.\n")); + return EINVAL; + } + + tmp_ctx = talloc_new(NULL); + if (tmp_ctx == NULL) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Out of memory.\n")); + return ENOMEM; + } + + name = talloc_strdup(tmp_ctx, (*mc_ctx)->name); + if (name == NULL) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Out of memory.\n")); + ret = ENOMEM; + goto done; + } + + type = (*mc_ctx)->type; + ret = talloc_free(*mc_ctx); + if (ret != 0) { + /* This can happen only if destructor is associated with this + * context */ + DEBUG(SSSDBG_MINOR_FAILURE, ("Destructor asociated with memory" + " context failed.\n")); + } + + ret = sss_mmap_cache_init(mem_ctx, name, type, n_elem, timeout, mc_ctx); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to re-initialize mmap cache.\n")); + goto done; + } + +done: + talloc_free(tmp_ctx); + return ret; +} |