|
|
|
|
@ -173,8 +173,8 @@ static struct ms_session* ms_create(struct merkle_sync* ms, struct ETCP_CONN* co
|
|
|
|
|
snprintf(s->tree_ns, sizeof(s->tree_ns), "%u:%s", dataset, s->ns); |
|
|
|
|
s->leader = ms->inst->node_id < s->peer; |
|
|
|
|
s->next = ms->sessions; ms->sessions = s; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: attach ns=%s peer=%016llx conn=%p leader=%d", |
|
|
|
|
s->ns, (unsigned long long)s->peer, (void*)conn, s->leader); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: attach dataset=%u ns=%s peer=%016llx conn=%p leader=%d", |
|
|
|
|
s->dataset->id, s->ns, (unsigned long long)s->peer, (void*)conn, s->leader); |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -208,8 +208,8 @@ static void ms_sent(struct ll_queue* q, void* arg) {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
s->sent_bytes += len; |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: TX ns=%s peer=%016llx round=%llu type=%u bytes=%zu", |
|
|
|
|
s->ns, (unsigned long long)s->peer, (unsigned long long)s->round, type, len); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: TX dataset=%u ns=%s peer=%016llx round=%llu type=%u bytes=%zu", |
|
|
|
|
s->dataset->id, s->ns, (unsigned long long)s->peer, (unsigned long long)s->round, type, len); |
|
|
|
|
if (type == MS_ERROR) { |
|
|
|
|
s->state = MS_FAILED; |
|
|
|
|
ms_stop_deadline(s); |
|
|
|
|
@ -221,8 +221,8 @@ static void ms_sent(struct ll_queue* q, void* arg) {
|
|
|
|
|
ms_stop_deadline(s); |
|
|
|
|
if (s->revision == s->verified_revision) { |
|
|
|
|
s->dirty = 0; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: converged ns=%s peer=%016llx round=%llu tx=%llu rx=%llu", |
|
|
|
|
s->ns, (unsigned long long)s->peer, (unsigned long long)s->round, |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: converged dataset=%u ns=%s peer=%016llx round=%llu tx=%llu rx=%llu", |
|
|
|
|
s->dataset->id, s->ns, (unsigned long long)s->peer, (unsigned long long)s->round, |
|
|
|
|
(unsigned long long)s->sent_bytes, (unsigned long long)s->received_bytes); |
|
|
|
|
ms_notify(s, MT_OK); |
|
|
|
|
return; |
|
|
|
|
@ -254,8 +254,8 @@ static int ms_send(struct ms_session* s, int type, uint32_t request, const uint8
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void ms_fail(struct ms_session* s, int error, const char* reason, int report) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: failed ns=%s peer=%016llx round=%llu error=%d reason=%s", |
|
|
|
|
s->ns, (unsigned long long)s->peer, (unsigned long long)s->round, error, reason); |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: failed dataset=%u ns=%s peer=%016llx round=%llu error=%d reason=%s", |
|
|
|
|
s->dataset->id, s->ns, (unsigned long long)s->peer, (unsigned long long)s->round, error, reason); |
|
|
|
|
s->state = MS_FAILED; s->dirty = 0; s->waiting = 0; s->failure_error = error; |
|
|
|
|
if (s->work) { uasync_call_soon_cancel(s->ms->inst->ua, s->work); s->work = NULL; } |
|
|
|
|
ms_discard_tx(s); |
|
|
|
|
@ -333,8 +333,8 @@ static int ms_begin(struct ms_session* s) {
|
|
|
|
|
if (!s->round) return -1; |
|
|
|
|
s->request_id = s->remote_request_id = 0; |
|
|
|
|
s->state = MS_BEGIN_WAIT; s->dirty = 0; s->waiting = 0; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: begin ns=%s peer=%016llx round=%llu", |
|
|
|
|
s->ns, (unsigned long long)s->peer, (unsigned long long)s->round); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: begin dataset=%u ns=%s peer=%016llx round=%llu", |
|
|
|
|
s->dataset->id, s->ns, (unsigned long long)s->peer, (unsigned long long)s->round); |
|
|
|
|
return ms_send(s, MS_BEGIN, 0, NULL, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -485,8 +485,8 @@ static void ms_receive(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
|
|
|
|
s->received_bytes += entry->len; |
|
|
|
|
const uint8_t* p = d + MS_HEADER; |
|
|
|
|
size_t len = entry->len - MS_HEADER; |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: RX ns=%s peer=%016llx round=%llu type=%u request=%u bytes=%zu state=%d", |
|
|
|
|
ns, (unsigned long long)s->peer, (unsigned long long)round, type, request, len, s->state); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: RX dataset=%u ns=%s peer=%016llx round=%llu type=%u request=%u bytes=%zu state=%d", |
|
|
|
|
dataset, ns, (unsigned long long)s->peer, (unsigned long long)round, type, request, len, s->state); |
|
|
|
|
int rc = 0, notify = 0; |
|
|
|
|
if (s->state == MS_FAILING) goto done; |
|
|
|
|
if (type != MS_WAKE && type != MS_BEGIN && round != s->round) { |
|
|
|
|
@ -550,8 +550,8 @@ static void ms_receive(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
|
|
|
|
s->dirty = memcmp(root, p, sizeof(root)) != 0; |
|
|
|
|
if (s->dirty) rc = ms_schedule(s); |
|
|
|
|
else { |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: converged ns=%s peer=%016llx round=%llu", |
|
|
|
|
s->ns, (unsigned long long)s->peer, (unsigned long long)s->round); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "merkle_sync: converged dataset=%u ns=%s peer=%016llx round=%llu", |
|
|
|
|
s->dataset->id, s->ns, (unsigned long long)s->peer, (unsigned long long)s->round); |
|
|
|
|
notify = 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|