From 13ca3a8563b6ce461b32ebd5c1e039764dafad93 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 18 Oct 2011 10:20:10 +0200 Subject: [PATCH] fixed server, added symlink indicating aliveness of peers --- mars_server.c | 7 +++++++ sy_old/mars_light.c | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/mars_server.c b/mars_server.c index ef98abba..95446e1f 100644 --- a/mars_server.c +++ b/mars_server.c @@ -566,6 +566,13 @@ static int _server_thread(void *data) MARS_INF("-------- server starting on host '%s' ----------\n", id); + while (!kthread_should_stop() && + (!mars_global || !mars_global->global_power.button)) { + msleep(1000); + } + + MARS_INF("-------- server now working on host '%s' ----------\n", id); + while (!kthread_should_stop() && mars_global && mars_global->global_power.button) { struct server_brick *brick; struct mars_socket *new_socket; diff --git a/sy_old/mars_light.c b/sy_old/mars_light.c index 17605bd9..47bbfbcc 100644 --- a/sy_old/mars_light.c +++ b/sy_old/mars_light.c @@ -1037,7 +1037,7 @@ static int _make_peer(struct mars_global *global, struct mars_dent *dent, char * peer = dent->d_private; if (!peer->peer_thread) { - peer->peer_thread = kthread_create(remote_thread, peer, "mars_remote%d", serial++); + peer->peer_thread = kthread_create(remote_thread, peer, "mars_peer%d", serial++); if (unlikely(IS_ERR(peer->peer_thread))) { MARS_ERR("cannot start peer thread, status = %d\n", (int)PTR_ERR(peer->peer_thread)); peer->peer_thread = NULL; @@ -2385,6 +2385,7 @@ enum { // replacement for DNS in kernelspace CL_IPS, CL_PEERS, + CL_ALIVE, // resource definitions CL_RESOURCE, CL_DEFAULTS0, @@ -2439,6 +2440,15 @@ static const struct light_class light_classes[] = { #endif .cl_backward = kill_scan, }, + /* Indicate aliveness of all cluster paritcipants + * by the timestamp of this link. + */ + [CL_ALIVE] = { + .cl_name = "alive-", + .cl_len = 6, + .cl_type = 'l', + .cl_father = CL_ROOT, + }, /* Directory containing all items of a resource */ @@ -2898,6 +2908,15 @@ void _show_statist(struct mars_global *global) } #endif +static +void _make_alivelink(bool alive) +{ + char *src = alive ? "1" : "0"; + char *dst = path_make("/mars/alive-%s", my_id()); + mars_symlink(src, dst, NULL, 0); + brick_string_free(dst); +} + static struct mars_global _global = { .dent_anchor = LIST_HEAD_INIT(_global.dent_anchor), .brick_anchor = LIST_HEAD_INIT(_global.brick_anchor), @@ -2930,6 +2949,8 @@ static int light_thread(void *data) int status; _global.global_power.button = !kthread_should_stop(); + _make_alivelink(_global.global_power.button); + #if 1 if (!_global.global_power.button) { mars_kill_brick_all(&_global, &_global.server_anchor, false);