[sheepdog] [PATCH 6/7] local: remove blocking event when its sender goes away

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


This avoids a dead lock.

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

diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index 39f39cd..609dfb0 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -267,15 +267,24 @@ static void check_pids(void *arg)
 	size_t nr;
 	struct sd_node nodes[SD_MAX_NODES];
 	pid_t pids[SD_MAX_NODES];
+	struct local_event *ev;
 
 	shm_queue_lock();
 
 	nr = get_nodes(nodes, pids);
 
 	for (i = 0; i < nr; i++)
-		if (!process_exists(pids[i]))
+		if (!process_exists(pids[i])) {
 			add_event(EVENT_LEAVE, nodes + i, NULL, 0);
 
+			/* unblock blocking event if sender has gone */
+			ev = shm_queue_peek_block_event();
+			if (node_eq(nodes + i, &ev->sender)) {
+				ev->removed = true;
+				msync(ev, sizeof(*ev), MS_SYNC);
+			}
+		}
+
 	shm_queue_unlock();
 
 	add_timer(arg, PROCESS_CHECK_INTERVAL);
-- 
1.7.2.5




More information about the sheepdog mailing list