cluster: STABLE2 - cman: fix cman_tool join return code
Christine Caulfield
chrissie@fedoraproject.org
Fri Dec 19 09:37:00 GMT 2008
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=9f83588fb64c6de54fc4a2c14814133f03662984
Commit: 9f83588fb64c6de54fc4a2c14814133f03662984
Parent: d036b16a47e93506c80dfa3c48c4f609f5d9338a
Author: Christine Caulfield <ccaulfie@redhat.com>
AuthorDate: Fri Dec 19 09:22:39 2008 +0000
Committer: Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Fri Dec 19 09:32:41 2008 +0000
cman: fix cman_tool join return code
Tha last checkin broke the cman_tool return code. The FORKED and SUCCESS
messages could (and in a normal run often would) be returned as part
of the same pipe read.
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
cman/cman_tool/join.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/cman/cman_tool/join.c b/cman/cman_tool/join.c
index 9635d4f..c08ee74 100644
--- a/cman/cman_tool/join.c
+++ b/cman/cman_tool/join.c
@@ -216,7 +216,7 @@ int join(commandline_t *comline)
}
be_daemon(!(comline->verbose & ~DEBUG_STARTUP_ONLY));
- sprintf(scratch, "FORKED: %d", getpid());
+ sprintf(scratch, "FORKED: %d\n", getpid());
write(p[1], scratch, strlen(scratch));
execve(AISEXECBIN, argv, envp);
@@ -242,6 +242,7 @@ int join(commandline_t *comline)
fd_set fds;
struct timeval tv={1, 0};
char message[1024];
+ char *messageptr = message;
FD_ZERO(&fds);
FD_SET(p[0], &fds);
@@ -254,14 +255,20 @@ int join(commandline_t *comline)
if ((len = read(p[0], message, sizeof(message)) > 0)) {
/* Forked OK - get the real aisexec pid */
- if (sscanf(message, "FORKED: %d", &aisexec_pid) == 1) {
+ if (sscanf(messageptr, "FORKED: %d", &aisexec_pid) == 1) {
if (comline->verbose & DEBUG_STARTUP_ONLY)
fprintf(stderr, "forked process ID is %d\n", aisexec_pid);
status = 1;
- continue;
+
+ /* There might be a SUCCESS message in the pipe too. */
+ messageptr = strchr(messageptr, '\n');
+ if (messageptr)
+ messageptr++;
+ else
+ continue;
}
/* Success! get the new PID of double-forked aisexec */
- if (sscanf(message, "SUCCESS: %d", &aisexec_pid) == 1) {
+ if (sscanf(messageptr, "SUCCESS: %d", &aisexec_pid) == 1) {
if (comline->verbose & DEBUG_STARTUP_ONLY)
fprintf(stderr, "aisexec running, process ID is %d\n", aisexec_pid);
status = 0;
More information about the Cluster-cvs
mailing list