lib: Remove memcache from gencache
authorVolker Lendecke <vl@samba.org>
Wed, 22 Jul 2015 13:50:00 +0000 (15:50 +0200)
committerRalph Boehme <slow@samba.org>
Mon, 7 Mar 2016 16:58:16 +0000 (17:58 +0100)
The main reason for this was to avoid access to the fcntl-governed transaction
based gencache.tdb. A later patch will make this unnecessary by filling
gencache_notrans more aggressively.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/gencache.c

index e3f860955e5e13d7a4f1e846469df6a831f4731d..a9b7fab4600d7bcbc494247c9803093e529c9a7f 100644 (file)
@@ -26,7 +26,6 @@
 #include "system/glob.h"
 #include "util_tdb.h"
 #include "tdb_wrap/tdb_wrap.h"
-#include "../lib/util/memcache.h"
 
 #undef  DBGC_CLASS
 #define DBGC_CLASS DBGC_TDB
@@ -35,7 +34,6 @@
 
 static struct tdb_wrap *cache;
 static struct tdb_wrap *cache_notrans;
-static int cache_notrans_seqnum;
 
 /**
  * @file gencache.c
@@ -124,7 +122,6 @@ static bool gencache_init(void)
        cache_notrans = tdb_wrap_open(NULL, cache_fname, 0,
                                      TDB_CLEAR_IF_FIRST|
                                      TDB_INCOMPATIBLE_HASH|
-                                     TDB_SEQNUM|
                                      TDB_NOSYNC|
                                      TDB_MUTEX_LOCKING,
                                      open_flags, 0644);
@@ -453,7 +450,6 @@ static bool gencache_pull_timeout(char *val, time_t *pres, char **pendptr)
 struct gencache_parse_state {
        void (*parser)(time_t timeout, DATA_BLOB blob, void *private_data);
        void *private_data;
-       bool is_memcache;
 };
 
 static int gencache_parse_fn(TDB_DATA key, TDB_DATA data, void *private_data)
@@ -476,12 +472,6 @@ static int gencache_parse_fn(TDB_DATA key, TDB_DATA data, void *private_data)
                endptr+1, data.dsize - PTR_DIFF(endptr+1, data.dptr));
        state->parser(t, blob, state->private_data);
 
-       if (!state->is_memcache) {
-               memcache_add(NULL, GENCACHE_RAM,
-                            data_blob_const(key.dptr, key.dsize),
-                            data_blob_const(data.dptr, data.dsize));
-       }
-
        return 0;
 }
 
@@ -492,7 +482,6 @@ bool gencache_parse(const char *keystr,
 {
        struct gencache_parse_state state;
        TDB_DATA key = string_term_tdb_data(keystr);
-       DATA_BLOB memcache_val;
        int ret;
 
        if (keystr == NULL) {
@@ -508,31 +497,6 @@ bool gencache_parse(const char *keystr,
        state.parser = parser;
        state.private_data = private_data;
 
-       if (memcache_lookup(NULL, GENCACHE_RAM,
-                           data_blob_const(key.dptr, key.dsize),
-                           &memcache_val)) {
-               /*
-                * Make sure that nobody has changed the gencache behind our
-                * back.
-                */
-               int current_seqnum = tdb_get_seqnum(cache_notrans->tdb);
-               if (current_seqnum == cache_notrans_seqnum) {
-                       /*
-                        * Ok, our memcache is still current, use it without
-                        * going to the tdb files.
-                        */
-                       state.is_memcache = true;
-                       gencache_parse_fn(key, make_tdb_data(memcache_val.data,
-                                                            memcache_val.length),
-                                         &state);
-                       return true;
-               }
-               memcache_flush(NULL, GENCACHE_RAM);
-               cache_notrans_seqnum = current_seqnum;
-       }
-
-       state.is_memcache = false;
-
        ret = tdb_parse_record(cache_notrans->tdb, key,
                               gencache_parse_fn, &state);
        if (ret == 0) {