public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: master - cman: fix notifyd loop
@ 2009-02-10 12:02 Fabio M. Di Nitto
0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2009-02-10 12:02 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=723c5e45265a16ef45f50516d367fdf4b79b7605
Commit: 723c5e45265a16ef45f50516d367fdf4b79b7605
Parent: 05b74a2cf746360758713cc9eec147576eae470d
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Wed Feb 4 09:49:28 2009 +0100
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Tue Feb 10 13:02:15 2009 +0100
cman: fix notifyd loop
stop polling to check if there are notifications.
Use cman_fd+select instead.
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
cman/notifyd/main.c | 41 +++++++++++++++++++++++++++--------------
1 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/cman/notifyd/main.c b/cman/notifyd/main.c
index 6aae796..7722032 100644
--- a/cman/notifyd/main.c
+++ b/cman/notifyd/main.c
@@ -10,6 +10,7 @@
#include <sched.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/select.h>
#include <libcman.h>
#include <ccs.h>
@@ -334,25 +335,37 @@ out:
static void loop()
{
- int rv;
-
- for (;;) {
- rv = cman_dispatch(cman_handle, CMAN_DISPATCH_ONE);
- if (rv == -1 && errno == EHOSTDOWN) {
+ int cd_result, se_result;
+ fd_set read_fds;
+ int cman_fd;
+
+ do {
+ FD_ZERO (&read_fds);
+ cman_fd = cman_get_fd(cman_handle);
+ FD_SET (cman_fd, &read_fds);
+ se_result = select((cman_fd + 1), &read_fds, 0, 0, 0);
+ if (se_result == -1) {
+ logt_print(LOG_CRIT, "Unable to select on cman_fd: %s\n", strerror(errno));
byebye_cman();
- logt_print(LOG_DEBUG, "waiting for cman to reappear..\n");
- setup_cman(1);
- logt_print(LOG_DEBUG, "cman is back..\n");
+ exit(EXIT_FAILURE);
}
- if (daemon_quit) {
- logt_print(LOG_DEBUG, "shutting down...\n");
- byebye_cman();
- exit(EXIT_SUCCESS);
+ if (FD_ISSET(cman_fd, &read_fds)) {
+ cd_result = 1;
+ while (cd_result > 0) {
+ cd_result = cman_dispatch(cman_handle, CMAN_DISPATCH_ONE);
+ if (cd_result == -1 && errno == EHOSTDOWN) {
+ byebye_cman();
+ logt_print(LOG_DEBUG, "waiting for cman to reappear..\n");
+ setup_cman(1);
+ logt_print(LOG_DEBUG, "cman is back..\n");
+ }
+ }
}
+ } while (se_result && !daemon_quit);
- sleep(1);
- }
+ logt_print(LOG_DEBUG, "shutting down...\n");
+ byebye_cman();
}
int main(int argc, char **argv)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-02-10 12:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-10 12:02 cluster: master - cman: fix notifyd loop Fabio M. Di Nitto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).