public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - notifyd: fix lockfile handling and exit path
@ 2009-03-20  5:30 Fabio M. Di Nitto
  0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2009-03-20  5:30 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a0a24f22c55e6c7ca4b582dc42d368bd6e8d9d98
Commit:        a0a24f22c55e6c7ca4b582dc42d368bd6e8d9d98
Parent:        7df83f541d621054aab903e550d4afede8f1375f
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Fri Mar 20 06:26:47 2009 +0100
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Fri Mar 20 06:26:47 2009 +0100

notifyd: fix lockfile handling and exit path

make sure to unlink our pid file on exit.

on exit, we often interrupt in the select operation.
this leads to select returnint an error and instead of
processing the normal exit path, we handling the error.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 cman/notifyd/main.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/cman/notifyd/main.c b/cman/notifyd/main.c
index 0f60f60..7a96444 100644
--- a/cman/notifyd/main.c
+++ b/cman/notifyd/main.c
@@ -94,6 +94,11 @@ static void read_arguments(int argc, char **argv)
 	}
 }
 
+static void remove_lockfile(void)
+{
+	unlink(LOCKFILE_NAME);
+}
+
 static void lockfile(void)
 {
 	int fd, error;
@@ -134,6 +139,8 @@ static void lockfile(void)
 		fprintf(stderr, "cannot write lock file %s\n", LOCKFILE_NAME);
 		exit(EXIT_FAILURE);
 	}
+
+	atexit(remove_lockfile);
 }
 
 static void sigterm_handler(int sig)
@@ -356,6 +363,10 @@ static void loop()
 		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 (daemon_quit)
+			goto out;
+
 		if (se_result == -1) {
 			logt_print(LOG_CRIT, "Unable to select on cman_fd: %s\n", strerror(errno));
 			byebye_cman();
@@ -376,6 +387,7 @@ static void loop()
 		}
 	} while (se_result && !daemon_quit);
 
+out:
 	logt_print(LOG_DEBUG, "shutting down...\n");
 	byebye_cman();
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-20  5:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-20  5:30 cluster: STABLE3 - notifyd: fix lockfile handling and exit path 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).