[sheepdog] [PATCH 4/7] local: avoid calling sd_block_handler twice

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Sep 4 10:05:40 CEST 2012


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/cluster/local.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index f861d23..88a2fd4 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -46,6 +46,7 @@ struct local_event {
 	enum local_event_type type;
 	struct sd_node sender;
 
+	bool callbacked;
 	bool removed;
 
 	size_t buf_len;
@@ -358,6 +359,9 @@ static bool local_process_event(void)
 	if (ev->removed)
 		goto out;
 
+	if (ev->callbacked)
+		return false; /* wait for unblock event */
+
 	switch (ev->type) {
 	case EVENT_JOIN_REQUEST:
 		if (!node_eq(&ev->nodes[0], &this_node))
@@ -394,7 +398,8 @@ static bool local_process_event(void)
 		sd_leave_handler(&ev->sender, ev->nodes, ev->nr_nodes);
 		break;
 	case EVENT_BLOCK:
-		sd_block_handler(&ev->sender);
+		ev->callbacked = sd_block_handler(&ev->sender);
+		msync(ev, sizeof(*ev), MS_SYNC);
 		return false;
 	case EVENT_NOTIFY:
 		sd_notify_handler(&ev->sender, ev->buf, ev->buf_len);
-- 
1.7.2.5




More information about the sheepdog mailing list