summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2013-04-16 13:14:51 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-04-17 11:39:57 +0200
commit714ba5f50551a42df324714358dc379b351d4a53 (patch)
tree242a59380ec9bfc783098f2f8d4829489b35a5e5
parent8e195a545d41647e591c1d06082133cbd25dc0a4 (diff)
downloadsssd-714ba5f50551a42df324714358dc379b351d4a53.tar.gz
sssd-714ba5f50551a42df324714358dc379b351d4a53.tar.bz2
sssd-714ba5f50551a42df324714358dc379b351d4a53.zip
Inform about function duplication.
sss_mc_set_recycled is a static function, that should not be used outside nsssrv_mmap_cache.c. The sss_cache tool is an exception, because in the case when sssd is not running, sss_cache must invalidate the memory cache file. That is why sss_mc_set_recycled was copied to the tools_mc_util.c (as helper function for sss_memcache_invalidate function). It was duplicated to allow this function to remain static (and invisible to any .h files), so that it is not used anywhere else. Wrong usage of this function might cause race conditions and corrupt the cache. I'll add comments about the duplication to the code.
-rw-r--r--src/responder/nss/nsssrv_mmap_cache.c3
-rw-r--r--src/tools/tools_mc_util.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c
index ec05f761..49878fcf 100644
--- a/src/responder/nss/nsssrv_mmap_cache.c
+++ b/src/responder/nss/nsssrv_mmap_cache.c
@@ -768,6 +768,9 @@ done:
* initialization
***************************************************************************/
+/* Copy of sss_mc_set_recycled is present in the src/tools/tools_mc_util.c.
+ * If you modify this function, you should modify the duplicated function
+ * too. */
static errno_t sss_mc_set_recycled(int fd)
{
uint32_t w = SSS_MC_HEADER_RECYCLED;
diff --git a/src/tools/tools_mc_util.c b/src/tools/tools_mc_util.c
index d623c48c..b563fac3 100644
--- a/src/tools/tools_mc_util.c
+++ b/src/tools/tools_mc_util.c
@@ -28,6 +28,9 @@
#include "util/mmap_cache.h"
#include "sss_client/sss_cli.h"
+/* This is a copy of sss_mc_set_recycled present in
+ * src/responder/nss/nsssrv_mmap_cache.c. If you modify this function,
+ * you should modify the original function too. */
static errno_t sss_mc_set_recycled(int fd)
{
uint32_t w = SSS_MC_HEADER_RECYCLED;