[sheepdog] [PATCH 2/7] local: check process at shorter intervals
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Tue Sep 4 10:05:38 CEST 2012
Some testcases regards that sheep can detect node failure in less than
1 second. This patch changes the interval of process check from 1
second to 200 milliseconds.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
include/event.h | 2 +-
lib/event.c | 5 +++--
sheep/cluster/local.c | 5 +++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/event.h b/include/event.h
index 39dfb7e..b0e7552 100644
--- a/include/event.h
+++ b/include/event.h
@@ -18,6 +18,6 @@ struct timer {
void *data;
};
-void add_timer(struct timer *t, unsigned int seconds);
+void add_timer(struct timer *t, unsigned int mseconds);
#endif
diff --git a/lib/event.c b/lib/event.c
index 1557493..a1a0b38 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -40,7 +40,7 @@ static void timer_handler(int fd, int events, void *data)
close(fd);
}
-void add_timer(struct timer *t, unsigned int seconds)
+void add_timer(struct timer *t, unsigned int mseconds)
{
struct itimerspec it;
int tfd;
@@ -52,7 +52,8 @@ void add_timer(struct timer *t, unsigned int seconds)
}
memset(&it, 0, sizeof(it));
- it.it_value.tv_sec = seconds;
+ it.it_value.tv_sec = mseconds / 1000;
+ it.it_value.tv_nsec = (mseconds % 1000) * 1000000;
if (timerfd_settime(tfd, 0, &it, NULL) < 0) {
eprintf("timerfd_settime: %m\n");
diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index a5b28b6..1fcce19 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -25,6 +25,7 @@
#include "work.h"
#define MAX_EVENTS 500
+#define PROCESS_CHECK_INTERVAL 200 /* ms */
const char *shmfile = "/tmp/sheepdog_shm";
static int shmfd;
@@ -247,7 +248,7 @@ static void check_pids(void *arg)
shm_queue_unlock();
- add_timer(arg, 1);
+ add_timer(arg, PROCESS_CHECK_INTERVAL);
}
@@ -434,7 +435,7 @@ static int local_init(const char *option)
return -1;
}
- add_timer(&t, 1);
+ add_timer(&t, PROCESS_CHECK_INTERVAL);
ret = register_event(sigfd, local_handler, NULL);
if (ret) {
--
1.7.2.5
More information about the sheepdog
mailing list