summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
df13375)
It hurts, but I think this global variable is necessary for transition, and it
has the potential to remove quite a few other global variables without messing
with APIs too much.
(This used to be commit
c131d0dc52ec09c9227eff3d68877369c37aaed5)
struct memcache *memcache_init(TALLOC_CTX *mem_ctx, size_t max_size);
struct memcache *memcache_init(TALLOC_CTX *mem_ctx, size_t max_size);
+void memcache_set_global(struct memcache *cache);
+
void memcache_add(struct memcache *cache, enum memcache_number n,
DATA_BLOB key, DATA_BLOB value);
void memcache_add(struct memcache *cache, enum memcache_number n,
DATA_BLOB key, DATA_BLOB value);
#include "memcache.h"
#include "rbtree.h"
#include "memcache.h"
#include "rbtree.h"
+static struct memcache *global_cache;
+
struct memcache_element {
struct rb_node rb_node;
struct memcache_element *prev, *next;
struct memcache_element {
struct rb_node rb_node;
struct memcache_element *prev, *next;
+void memcache_set_global(struct memcache *cache)
+{
+ TALLOC_FREE(global_cache);
+ global_cache = cache;
+}
+
static struct memcache_element *memcache_node2elem(struct rb_node *node)
{
return (struct memcache_element *)
static struct memcache_element *memcache_node2elem(struct rb_node *node)
{
return (struct memcache_element *)
{
struct memcache_element *e;
{
struct memcache_element *e;
+ if (cache == NULL) {
+ cache = global_cache;
+ }
+ if (cache == NULL) {
+ return false;
+ }
+
e = memcache_find(cache, n, key);
if (e == NULL) {
return false;
e = memcache_find(cache, n, key);
if (e == NULL) {
return false;
{
struct memcache_element *e;
{
struct memcache_element *e;
+ if (cache == NULL) {
+ cache = global_cache;
+ }
+ if (cache == NULL) {
+ return;
+ }
+
e = memcache_find(cache, n, key);
if (e == NULL) {
return;
e = memcache_find(cache, n, key);
if (e == NULL) {
return;
DATA_BLOB cache_key, cache_value;
size_t element_size;
DATA_BLOB cache_key, cache_value;
size_t element_size;
+ if (cache == NULL) {
+ cache = global_cache;
+ }
+ if (cache == NULL) {
+ return;
+ }
+
if (key.length == 0) {
return;
}
if (key.length == 0) {
return;
}
+ if (cache == NULL) {
+ cache = global_cache;
+ }
+ if (cache == NULL) {
+ return;
+ }
+
/*
* Find the smallest element of number n
*/
/*
* Find the smallest element of number n
*/
if (smbd_messaging_context() == NULL)
exit(1);
if (smbd_messaging_context() == NULL)
exit(1);
+ if (smbd_memcache() == NULL) {
+ exit(1);
+ }
+
+ memcache_set_global(smbd_memcache());
+
/* Initialise the password backed before the global_sam_sid
to ensure that we fetch from ldap before we make a domain sid up */
/* Initialise the password backed before the global_sam_sid
to ensure that we fetch from ldap before we make a domain sid up */