kcplantdb.h   kcplantdb.h 
skipping to change at line 1000 skipping to change at line 1000
node->lock.lock_writer(); node->lock.lock_writer();
} else { } else {
node->lock.lock_reader(); node->lock.lock_reader();
} }
bool reorg = accept_impl(node, rec, visitor); bool reorg = accept_impl(node, rec, visitor);
bool atran = autotran_ && !tran_ && node->dirty; bool atran = autotran_ && !tran_ && node->dirty;
bool async = autosync_ && !autotran_ && !tran_ && node->dirty; bool async = autosync_ && !autotran_ && !tran_ && node->dirty;
node->lock.unlock(); node->lock.unlock();
bool flush = false; bool flush = false;
bool err = false; bool err = false;
int64_t id = node->id;
if (atran && !reorg && !fix_auto_transaction_leaf(node)) err = true; if (atran && !reorg && !fix_auto_transaction_leaf(node)) err = true;
if (reorg && mlock_.promote()) { if (reorg && mlock_.promote()) {
if (!reorganize_tree(node, hist, hnum)) err = true; if (!reorganize_tree(node, hist, hnum)) err = true;
if (atran && !fix_auto_transaction_tree()) err = true; if (atran && !fix_auto_transaction_tree()) err = true;
reorg = false; reorg = false;
} else if (cusage_ > pccap_) { } else if (cusage_ > pccap_) {
int32_t idx = node->id % PDBSLOTNUM; int32_t idx = id % PDBSLOTNUM;
LeafSlot* lslot = lslots_ + idx; LeafSlot* lslot = lslots_ + idx;
if (!clean_leaf_cache_part(lslot)) err = true; if (!clean_leaf_cache_part(lslot)) err = true;
if (mlock_.promote()) { if (mlock_.promote()) {
if (!flush_leaf_cache_part(lslot)) err = true; if (!flush_leaf_cache_part(lslot)) err = true;
InnerSlot* islot = islots_ + idx; InnerSlot* islot = islots_ + idx;
if (islot->warm->count() > lslot->warm->count() + lslot->hot->count () + 1 && if (islot->warm->count() > lslot->warm->count() + lslot->hot->count () + 1 &&
!flush_inner_cache_part(islot)) err = true; !flush_inner_cache_part(islot)) err = true;
} else { } else {
flush = true; flush = true;
} }
} }
mlock_.unlock(); mlock_.unlock();
if (reorg) { if (reorg) {
mlock_.lock_writer(); mlock_.lock_writer();
node = search_tree(link, false, hist, &hnum); node = search_tree(link, false, hist, &hnum);
if (node) { if (node) {
if (!reorganize_tree(node, hist, hnum)) err = true; if (!reorganize_tree(node, hist, hnum)) err = true;
if (atran && !tran_ && !fix_auto_transaction_tree()) err = true; if (atran && !tran_ && !fix_auto_transaction_tree()) err = true;
} else {
set_error(_KCCODELINE_, Error::BROKEN, "search failed");
err = true;
} }
mlock_.unlock(); mlock_.unlock();
} else if (flush) { } else if (flush) {
int32_t idx = node->id % PDBSLOTNUM; int32_t idx = id % PDBSLOTNUM;
LeafSlot* lslot = lslots_ + idx; LeafSlot* lslot = lslots_ + idx;
mlock_.lock_writer(); mlock_.lock_writer();
if (!flush_leaf_cache_part(lslot)) err = true; if (!flush_leaf_cache_part(lslot)) err = true;
InnerSlot* islot = islots_ + idx; InnerSlot* islot = islots_ + idx;
if (islot->warm->count() > lslot->warm->count() + lslot->hot->count() + 1 && if (islot->warm->count() > lslot->warm->count() + lslot->hot->count() + 1 &&
!flush_inner_cache_part(islot)) err = true; !flush_inner_cache_part(islot)) err = true;
mlock_.unlock(); mlock_.unlock();
} }
if (rbuf != rstack) delete[] rbuf; if (rbuf != rstack) delete[] rbuf;
if (lbuf != lstack) delete[] lbuf; if (lbuf != lstack) delete[] lbuf;
skipping to change at line 2289 skipping to change at line 2287
delete node; delete node;
return !err; return !err;
} }
/** /**
* Save a leaf node. * Save a leaf node.
* @param node the leaf node. * @param node the leaf node.
* @return true on success, or false on failure. * @return true on success, or false on failure.
*/ */
bool save_leaf_node(LeafNode* node) { bool save_leaf_node(LeafNode* node) {
_assert_(node); _assert_(node);
ScopedSpinRWLock lock(&node->lock, true); ScopedSpinRWLock lock(&node->lock, false);
if (!node->dirty) return true; if (!node->dirty) return true;
bool err = false; bool err = false;
char hbuf[NUMBUFSIZ]; char hbuf[NUMBUFSIZ];
size_t hsiz = std::sprintf(hbuf, "%c%llX", PDBLNPREFIX, (long long)node ->id); size_t hsiz = std::sprintf(hbuf, "%c%llX", PDBLNPREFIX, (long long)node ->id);
if (node->dead) { if (node->dead) {
if (!db_.remove(hbuf, hsiz) && db_.error().code() != Error::NOREC) er r = true; if (!db_.remove(hbuf, hsiz) && db_.error().code() != Error::NOREC) er r = true;
} else { } else {
char* rbuf = new char[node->size]; char* rbuf = new char[node->size];
char* wp = rbuf; char* wp = rbuf;
wp += writevarnum(wp, node->prev); wp += writevarnum(wp, node->prev);
 End of changes. 5 change blocks. 
6 lines changed or deleted 4 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/