diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-05-21 18:04:47 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-05-21 18:04:47 +0200 |
commit | 20796bcf57a7f5e1921dc12e0568221f985fe4f2 (patch) | |
tree | 8f0540a602a9ea0031d656bc31c0b8bc1e91eb70 /source3/lib/memcache.c | |
parent | 323be4a6907e4915bb76aa103bf5b868f0b459b1 (diff) | |
parent | 1a416ff13ca7786f2e8d24c66addf00883e9cb12 (diff) | |
download | samba-20796bcf57a7f5e1921dc12e0568221f985fe4f2.tar.gz samba-20796bcf57a7f5e1921dc12e0568221f985fe4f2.tar.bz2 samba-20796bcf57a7f5e1921dc12e0568221f985fe4f2.zip |
Merge branch 'v3-3-test' of ssh://git.samba.org/data/git/samba into docbook
Conflicts:
source/Makefile.in
(This used to be commit 01987778a123f853fccdcb7fe9566143e2d7c490)
Diffstat (limited to 'source3/lib/memcache.c')
-rw-r--r-- | source3/lib/memcache.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/source3/lib/memcache.c b/source3/lib/memcache.c index 6dee61af50..e1426bc811 100644 --- a/source3/lib/memcache.c +++ b/source3/lib/memcache.c @@ -120,11 +120,11 @@ static int memcache_compare(struct memcache_element *e, enum memcache_number n, { DATA_BLOB this_key, this_value; - if ((int)e->n < (int)n) return -1; - if ((int)e->n > (int)n) return 1; + if ((int)e->n < (int)n) return 1; + if ((int)e->n > (int)n) return -1; - if (e->keylength < key.length) return -1; - if (e->keylength > key.length) return 1; + if (e->keylength < key.length) return 1; + if (e->keylength > key.length) return -1; memcache_element_parse(e, &this_key, &this_value); return memcmp(this_key.data, key.data, key.length); @@ -357,10 +357,18 @@ void memcache_flush(struct memcache *cache, enum memcache_number n) return; } + /* + * First, find *any* element of number n + */ + while (true) { struct memcache_element *elem = memcache_node2elem(node); struct rb_node *next; + if ((int)elem->n == (int)n) { + break; + } + if ((int)elem->n < (int)n) { next = node->rb_right; } @@ -373,15 +381,36 @@ void memcache_flush(struct memcache *cache, enum memcache_number n) node = next; } - node = rb_next(node); if (node == NULL) { return; } + /* + * Then, find the leftmost element with number n + */ + + while (true) { + struct rb_node *prev = rb_prev(node); + struct memcache_element *elem; + + if (prev == NULL) { + break; + } + elem = memcache_node2elem(prev); + if ((int)elem->n != (int)n) { + break; + } + node = prev; + } + while (node != NULL) { struct memcache_element *e = memcache_node2elem(node); struct rb_node *next = rb_next(node); + if (e->n != n) { + break; + } + memcache_delete_element(cache, e); node = next; } |