Commit 3ce1f7ce authored by Vincenzo Liberatore's avatar Vincenzo Liberatore

Addresses #337

Fixes the tests with a bound on the number of ranges, and fixes a bug
in lock tree unlock

git-svn-id: file:///svn/tokudb@2125 c7de825b-a66e-492c-adef-691d508d4ae1
parent ccb9a0f1
# On OSX do:
# make OSX=OSX
LIBNAME=liblocktree
LIBNAME=liblocktree_linear
ifneq ($(OPT),)
OPTFLAGS = -O3
OPTFLAGS = -O0 -g3 -ggdb3
else
OPTFLAGS = -O2 -g3 -ggdb3
endif
......
......@@ -1186,14 +1186,15 @@ int toku_lt_unlock(toku_lock_tree* tree, DB_TXN* txn) {
toku_range_tree *selfread = __toku_lt_ifexist_selfread (tree, txn);
u_int32_t ranges = 0;
if (selfwrite) {
ranges = toku_rt_get_size(selfwrite);
if (selfread) {
ranges = toku_rt_get_size(selfread);
r = __toku_lt_free_contents(tree, selfread, tree->mainread);
if (r!=0) return __toku_lt_panic(tree, r);
}
if (selfread) {
ranges += toku_rt_get_size(selfread);
if (selfwrite) {
ranges += toku_rt_get_size(selfwrite);
r = __toku_lt_border_delete(tree, selfwrite);
if (r!=0) return __toku_lt_panic(tree, r);
}
......
......@@ -40,7 +40,8 @@ int dbcmp (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
BOOL panicked = FALSE;
int dbpanic(DB* db) {
int dbpanic(DB* db, int r) {
r++;
if (verbose) printf("AHH!!!! Run away %p!!!\n", db);
panicked = TRUE;
assert(want_panic);
......
......@@ -5,10 +5,11 @@ int main() {
toku_lock_tree* lt = NULL;
DB* db = (DB*)1;
u_int32_t mem = 4096 * 1000;
u_int32_t memcnt;
u_int32_t memcnt = 0;
BOOL duplicates;
for (duplicates = 0; duplicates < 2; duplicates++) {
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR(r);
......
......@@ -7,7 +7,7 @@ static DBT _data;
DBT* key;
DBT* data;
u_int32_t mem = 4096 * 1000;
u_int32_t memcnt;
u_int32_t memcnt = 0;
static void do_range_test(int (*acquire)(toku_lock_tree*, DB_TXN*,
const DBT*, const DBT*,
......@@ -40,6 +40,7 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB_TXN*,
reverse_data_l = &_data_l;
reverse_data_r = &_data_r;
}
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR(r);
......@@ -142,6 +143,7 @@ static void do_point_test(int (*acquire)(toku_lock_tree*, DB_TXN*,
reverse_data = &_data;
data = NULL;
}
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR(r);
......@@ -195,42 +197,52 @@ int main(int argc, const char *argv[]) {
/* create tests. */
for (duplicates = 0; duplicates < 2; duplicates++) {
memcnt = 0;
r = toku_lt_create(NULL, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, NULL, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, NULL, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
u_int32_t old_mem = mem;
mem = 0;
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
mem = old_mem;
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, NULL,
NULL, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
NULL, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, NULL,
toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp,
NULL, toku_free, toku_realloc);
CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, NULL, toku_realloc);
CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, NULL);
CKERR2(r, EINVAL);
......
......@@ -9,7 +9,8 @@ int r;
toku_lock_tree* lt = NULL;
DB* db = (DB*)1;
DB_TXN* txn = (DB_TXN*)1;
size_t mem = 4096 * 1000;
u_int32_t mem = 4096 * 1000;
u_int32_t memcnt = 0;
BOOL duplicates = FALSE;
int nums[100];
......@@ -46,7 +47,8 @@ void init_query(BOOL dups) {
}
void setup_tree(BOOL dups) {
r = toku_lt_create(&lt, db, dups, dbpanic, mem, dbcmp, dbcmp,
memcnt = 0;
r = toku_lt_create(&lt, db, dups, dbpanic, mem, &memcnt, dbcmp, dbcmp,
toku_malloc, toku_free, toku_realloc);
CKERR(r);
assert(lt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment