Commit 20f87b44 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4880], fix toku_brtheader_get_some_existing_brt

git-svn-id: file:///svn/toku/tokudb@43434 c7de825b-a66e-492c-adef-691d508d4ae1
parent 81846ced
......@@ -550,7 +550,7 @@ int toku_remove_brtheader (struct brt_header* h, char **error_string, BOOL oplsn
BRT toku_brtheader_get_some_existing_brt(struct brt_header* h) {
BRT brt_ret = NULL;
toku_brtheader_lock(h);
if (toku_list_empty(&h->live_brts)) {
if (!toku_list_empty(&h->live_brts)) {
brt_ret = toku_list_struct(toku_list_head(&h->live_brts), struct brt, live_brt_link);
}
toku_brtheader_unlock(h);
......@@ -826,8 +826,10 @@ static int find_xid (OMTVALUE v, void *txnv) {
return 0;
}
void
// returns if ref was added
BOOL
toku_brtheader_maybe_add_txn_ref(struct brt_header* h, TOKUTXN txn) {
BOOL ref_added = FALSE;
OMTVALUE txnv;
u_int32_t index;
toku_brtheader_lock(h);
......@@ -836,13 +838,16 @@ toku_brtheader_maybe_add_txn_ref(struct brt_header* h, TOKUTXN txn) {
if (r==0) {
// It's already there.
assert((TOKUTXN)txnv==txn);
return 0;
ref_added = FALSE;
}
// Otherwise it's not there.
// Insert reference to transaction into brt
r = toku_omt_insert_at(h->txns, txn, index);
assert(r==0);
ref_added = TRUE;
exit:
toku_brtheader_unlock(h);
return ref_added;
}
void
......
......@@ -53,7 +53,7 @@ void toku_reset_root_xid_that_created(struct brt_header* h, TXNID new_root_xid_t
// This redefines which xid created the dictionary.
void
BOOL
toku_brtheader_maybe_add_txn_ref(struct brt_header* h, TOKUTXN txn);
void
toku_brtheader_remove_txn_ref(struct brt_header* h, TOKUTXN txn);
......
......@@ -685,10 +685,12 @@ static int find_filenum (OMTVALUE v, void *hv) {
//Notify a transaction that it has touched a brt.
int toku_txn_note_brt (TOKUTXN txn, struct brt_header* h) {
toku_brtheader_maybe_add_txn_ref(h, txn);
BOOL ref_added = toku_brtheader_maybe_add_txn_ref(h, txn);
// Insert reference to brt into transaction
int r = toku_omt_insert(txn->open_brt_headers, h, find_filenum, h, 0);
assert(r==0);
if (ref_added) {
int r = toku_omt_insert(txn->open_brt_headers, h, find_filenum, h, 0);
assert(r==0);
}
return 0;
}
......
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