Commit c2fb35e3 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #346

Modified svn:ignore properties to ignore unneeded information.

git-svn-id: file:///svn/tokudb@2136 c7de825b-a66e-492c-adef-691d508d4ae1
parent 39812632
......@@ -24,6 +24,10 @@ inline static int __toku_lt_panic(toku_lock_tree *tree, int r) {
return tree->panic(tree->db, r);
}
inline static int __toku_lt_callback(toku_lock_tree *tree, DB_TXN* txn) {
return tree->lock_callback ? tree->lock_callback(txn, tree) : 0;
}
const u_int32_t __toku_default_buflen = 2;
static const DBT __toku_lt_infinity;
......@@ -424,7 +428,7 @@ static int __toku_lt_check_borderwrite_conflict(toku_lock_tree* tree,
if (r!=0) return r;
conflict = met ? TOKU_YES_CONFLICT : TOKU_NO_CONFLICT;
}
if (conflict == TOKU_YES_CONFLICT) return DB_LOCK_NOTGRANTED;
if (conflict == TOKU_YES_CONFLICT) return DB_LOCK_DEADLOCK;
assert(conflict == TOKU_NO_CONFLICT);
return 0;
}
......@@ -750,6 +754,9 @@ static int __toku_lt_preprocess(toku_lock_tree* tree, DB_TXN* txn,
/* Verify left <= right, otherwise return EDOM. */
if (__toku_r_backwards(query)) return EDOM;
tree->dups_final = TRUE;
int r = __toku_lt_callback(tree, txn);
if (r!=0) return r;
return 0;
}
......@@ -1032,7 +1039,7 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB_TXN* txn,
mainread = tree->mainread; assert(mainread);
r = __toku_lt_meets_peer(tree, &query, mainread, txn, &met);
if (r!=0) return r;
if (met) return DB_LOCK_NOTGRANTED;
if (met) return DB_LOCK_DEADLOCK;
/*
else if 'K' meets borderwrite at 'peer' ('peer'!='txn') &&
'K' meets selfwrite('peer') then return failure.
......@@ -1212,3 +1219,11 @@ int toku_lt_set_dups(toku_lock_tree* tree, BOOL duplicates) {
tree->duplicates = duplicates;
return 0;
}
int toku_lt_set_txn_callback(toku_lock_tree* tree,
int (*callback)(DB_TXN*, toku_lock_tree*)) {
if (!tree || !callback) return EINVAL;
if (!tree->dups_final) return EDOM;
tree->lock_callback = callback;
return 0;
}
......@@ -58,9 +58,9 @@ typedef enum {
char* toku_lt_strerror(TOKU_LT_ERROR r) __attribute__((const,pure));
#define TOKU_LOCK_TREE_DEFINED
typedef struct __toku_lock_tree toku_lock_tree;
/** \brief The lock tree structure */
typedef struct __toku_lock_tree {
struct __toku_lock_tree {
/** The database for which this locktree will be handling locks */
DB* db;
/** Whether the db supports duplicate */
......@@ -78,6 +78,8 @@ typedef struct __toku_lock_tree {
u_int32_t max_ranges;
/** The current number of ranges. */
u_int32_t* num_ranges;
/** The lock callback function. */
int (*lock_callback)(DB_TXN*, toku_lock_tree*);
/** The key compare function */
int (*compare_fun)(DB*,const DBT*,const DBT*);
/** The data compare function */
......@@ -90,7 +92,7 @@ typedef struct __toku_lock_tree {
void (*free) (void*);
/** The user realloc function */
void* (*realloc)(void*, size_t);
} toku_lock_tree;
};
extern const DBT* const toku_lt_infinity; /**< Special value denoting
......@@ -372,4 +374,16 @@ int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB_TXN* txn,
*/
int toku_lt_unlock(toku_lock_tree* tree, DB_TXN* txn);
/**
Set a callback function to run after parameter checking but before
any locks.
This can be called after create, but NOT after any locks or unlocks have
occurred.
Return: 0 on success.
Return: EINVAL if tree is NULL
Return: EDOM if it is too late to change.
*/
int toku_lt_set_txn_callback(toku_lock_tree* tree,
int (*callback)(DB_TXN*, toku_lock_tree*));
#endif
......@@ -34,7 +34,7 @@ endif
install: $(LIBNAME_LINEAR).$(LIBEXT) $(LIBNAME_LINEAR).a #$(LIBNAME_TLOG).$(LIBEXT) $(LIBNAME_TLOG).a $(LIBNAME_LOG).$(LIBEXT) $(LIBNAME_LOG).a
clean:
rm -rf *.o
rm -rf *.o *.gcno *.gcda *.gcov
rm -rf $(LIBNAME_LINEAR).$(LIBEXT) $(LIBNAME_LINEAR).a
rm -rf $(LIBNAME_TLOG).$(LIBEXT) $(LIBNAME_TLOG).a
rm -rf $(LIBNAME_LOG).$(LIBEXT) $(LIBNAME_LOG).a
......
......@@ -30,6 +30,7 @@ const char *toku_copyright_string = "Copyright (c) 2007, 2008 Tokutek Inc. All
#define TOKU_LT_LINEAR
#include <locktree.h>
#include <lth.h>
const u_int32_t __toku_env_default_max_locks = 1000;
......
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