From a8d4d17ea3f5f6a02edfee83a1b59b2bbcc1b0c8 Mon Sep 17 00:00:00 2001
From: Yoni Fogel <yoni@tokutek.com>
Date: Mon, 17 Mar 2008 21:26:45 +0000
Subject: [PATCH] Addresses #523 Fixes a bug with escalation caught by
 valgrind.

git-svn-id: file:///svn/tokudb@2904 c7de825b-a66e-492c-adef-691d508d4ae1
---
 src/lock_tree/locktree.c                         | 2 +-
 src/lock_tree/tests/test.h                       | 6 ------
 src/lock_tree/tests/test_00060_lock_escalation.c | 3 ++-
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/lock_tree/locktree.c b/src/lock_tree/locktree.c
index 2a3ca2833f3..1dae8aba807 100644
--- a/src/lock_tree/locktree.c
+++ b/src/lock_tree/locktree.c
@@ -1177,7 +1177,7 @@ static inline int toku__escalate_reads_from_border_range(toku_lock_tree* tree,
     u_int32_t i;
     u_int32_t removed = 0;
     for (i = 0; i < numfound; i++) {
-        if (!toku__dominated(&tree->buf[0], border_range)) { continue; }
+        if (!toku__dominated(&tree->buf[i], border_range)) { continue; }
         r = toku_rt_delete(self_read, &tree->buf[i]);
         if (r != 0) { r = toku__lt_panic(tree, r); goto cleanup; }
 #if !defined(TOKU_RT_NOOVERLAPS)
diff --git a/src/lock_tree/tests/test.h b/src/lock_tree/tests/test.h
index 8ba02439dcc..2b57c2a3df5 100644
--- a/src/lock_tree/tests/test.h
+++ b/src/lock_tree/tests/test.h
@@ -41,12 +41,6 @@ int intcmp(DB *db __attribute__((__unused__)), const DBT* a, const DBT* b) {
     return x - y;
 }
 
-int charcmp(DB *db __attribute__((__unused__)), const DBT* a, const DBT* b) {
-    int x = *(char*)a->data;
-    int y = *(char*)b->data;
-
-    return x - y;
-}
 
 int dbcmp (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
     return toku_keycompare(a->data, a->size, b->data, b->size);
diff --git a/src/lock_tree/tests/test_00060_lock_escalation.c b/src/lock_tree/tests/test_00060_lock_escalation.c
index 985c343cfe8..f6a21fa4401 100644
--- a/src/lock_tree/tests/test_00060_lock_escalation.c
+++ b/src/lock_tree/tests/test_00060_lock_escalation.c
@@ -47,7 +47,8 @@ void init_query(BOOL dups) {
 
 void setup_tree(BOOL dups) {
     num_locks = 0;
-    r = toku_lt_create(&lt, db, dups, dbpanic, &max_locks, &num_locks, intcmp, charcmp,
+    assert(lt == NULL);
+    r = toku_lt_create(&lt, db, dups, dbpanic, &max_locks, &num_locks, intcmp, intcmp,
                        toku_malloc, toku_free, toku_realloc);
     CKERR(r);
     assert(lt);
-- 
2.30.9