Skip to content
Snippets Groups Projects
Commit 190e201a authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy Committed by Konstantin Osipov
Browse files

swim: make members array decoder be a separate function

At this moment SWIM protocol stores array of members only in one
place: inside the anti-entropy component. Its decoding is a
simple loop taking the member definitions one by one and
upserting them into the member table.

But the dissemination also has something kinda like members
array: an array of events. The trick is that an event is
basically the same as a member +/- a couple of optional fields.
Events are also decoded into the member definition structure. It
means that anti-entropy decoder can be easily reused.

Part of #3234
parent afbc8504
No related branches found
No related tags found
No related merge requests found
......@@ -1019,12 +1019,14 @@ swim_upsert_member(struct swim *swim, const struct swim_member_def *def,
return 0;
}
/** Decode an anti-entropy message, update member table. */
/**
* Decode a bunch of members encoded as a MessagePack array. Each
* correctly decoded member is upserted into the member table.
*/
static int
swim_process_anti_entropy(struct swim *swim, const char **pos, const char *end)
swim_process_members(struct swim *swim, const char *prefix,
const char **pos, const char *end)
{
say_verbose("SWIM %d: process anti-entropy", swim_fd(swim));
const char *prefix = "invalid anti-entropy message:";
uint32_t size;
if (swim_decode_array(pos, end, &size, prefix, "root") != 0)
return -1;
......@@ -1044,6 +1046,15 @@ swim_process_anti_entropy(struct swim *swim, const char **pos, const char *end)
return 0;
}
/** Decode an anti-entropy message, update member table. */
static int
swim_process_anti_entropy(struct swim *swim, const char **pos, const char *end)
{
say_verbose("SWIM %d: process anti-entropy", swim_fd(swim));
const char *prefix = "invalid anti-entropy message:";
return swim_process_members(swim, prefix, pos, end);
}
/**
* Decode a failure detection message. Schedule acks, process
* acks.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment