public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: "Fabio M. Di Nitto" <fabbione@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: STABLE3 - notifyd: fix lockfile handling and exit path
Date: Fri, 20 Mar 2009 05:30:00 -0000 [thread overview]
Message-ID: <20090320053011.11EA61202F9@lists.fedorahosted.org> (raw)
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();
}
reply other threads:[~2009-03-20 5:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090320053011.11EA61202F9@lists.fedorahosted.org \
--to=fabbione@fedoraproject.org \
--cc=cluster-cvs-relay@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).