tools: fix 'tail' show in mdbx_chk.

This commit is contained in:
Leo Yuriev 2017-05-26 12:00:05 +03:00
parent 5d836d2b03
commit d642127d10

View File

@ -638,42 +638,48 @@ static __inline int meta_recent(const bool roolback2steady) {
: 0; : 0;
} }
static __inline int meta_ancient(const bool roolback2steady) { static __inline int meta_tail(int head) {
if (meta_ot(envinfo.me_meta0_txnid, envinfo.me_meta0_sign, if (head == 0)
envinfo.me_meta1_txnid, envinfo.me_meta1_sign, roolback2steady)) return meta_ot(envinfo.me_meta1_txnid, envinfo.me_meta1_sign,
envinfo.me_meta2_txnid, envinfo.me_meta2_sign, true)
? 1
: 2;
if (head == 1)
return meta_ot(envinfo.me_meta0_txnid, envinfo.me_meta0_sign, return meta_ot(envinfo.me_meta0_txnid, envinfo.me_meta0_sign,
envinfo.me_meta2_txnid, envinfo.me_meta2_sign, envinfo.me_meta2_txnid, envinfo.me_meta2_sign, true)
roolback2steady)
? 0 ? 0
: 2; : 2;
return meta_ot(envinfo.me_meta2_txnid, envinfo.me_meta2_sign, if (head == 2)
envinfo.me_meta1_txnid, envinfo.me_meta1_sign, roolback2steady) return meta_ot(envinfo.me_meta0_txnid, envinfo.me_meta0_sign,
? 2 envinfo.me_meta1_txnid, envinfo.me_meta1_sign, true)
: 1; ? 0
: 1;
assert(false);
return -1;
} }
static int meta_steady_head(void) { return meta_recent(true); } static int meta_steady(void) { return meta_recent(true); }
static int meta_weak_head(void) { return meta_recent(false); } static int meta_head(void) { return meta_recent(false); }
static int meta_tail(void) { return meta_ancient(true); }
void verbose_meta(int num, txnid_t txnid, uint64_t sign) { void verbose_meta(int num, txnid_t txnid, uint64_t sign) {
print(" - meta-%d: %s %" PRIu64, num, meta_synctype(sign), txnid); print(" - meta-%d: %s %" PRIu64, num, meta_synctype(sign), txnid);
bool stay = true; bool stay = true;
if (num == meta_steady_head() && num == meta_weak_head()) { const int steady = meta_steady();
const int head = meta_head();
if (num == steady && num == head) {
print(", head"); print(", head");
stay = false; stay = false;
} else if (num == meta_steady_head()) { } else if (num == steady) {
print(", head-steady"); print(", head-steady");
stay = false; stay = false;
} else if (num == meta_weak_head()) { } else if (num == head) {
print(", head-weak"); print(", head-weak");
stay = false; stay = false;
} }
if (num == meta_tail()) { if (num == meta_tail(head)) {
print(", tail"); print(", tail");
stay = false; stay = false;
} }