[PATCH] node: do not delete my own node from a cluster
Export this patch
Because it will break the ctx->me pointer in the context, and will crash
horribly.
Signed-off-by: Louis Solofrizzo <lsolofrizzo@scaleway.com>
---
log.c | 2 +-
node.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/log.c b/log.c
index 9f43c18..544c344 100644
--- a/log.c
+++ b/log.c
@@ -181,7 +181,7 @@ bool libfloat_add_log(libfloat_ctx_t *ctx, libfloat_commit_type_t commit_type, l
/* User asked for snapshots, let's check it */
if (ctx->persistent.commit_index - ctx->persistent.snapshot.index >= ctx->conf.compact_every_n_log)
{
- ctx->soft_compact_last_log = ctx->persistent.commit_index + 1;
+ ctx->soft_compact_last_log = ctx->persistent.commit_index + 1;
ctx->append_snapshot_log(ctx, ctx->persistent.commit_index, ctx->persistent.term);
}
}
diff --git a/node.c b/node.c
index c01e92f..4900f1c 100644
--- a/node.c
+++ b/node.c
@@ -48,6 +48,13 @@ void libfloat_del_node(libfloat_ctx_t *ctx, libfloat_node_id_t id)
{
node = kh_val(ctx->nodes, iterator);
+ if (ctx->me == node)
+ {
+ /* Don't delete myself from the cluster, it will break things */
+ ERROR(ctx, "libfloat_del_node: Try to delete myself from the cluster, please fix your implementation");
+ return;
+ }
+
ctx->n_nodes--;
kh_del(libfloat_node_id_t, ctx->nodes, iterator);
ctx->free(node);
--
2.46.0
LG
-------- Original Message --------