This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

master - fence: Fix bug in make_args()


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3de140ad461dadfd99eadd4d37bc9d53ffd1b741
Commit:        3de140ad461dadfd99eadd4d37bc9d53ffd1b741
Parent:        69b3ecac8da9ce4a34efb6702b253e52ea87e063
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Fri Nov 7 17:33:20 2008 -0500
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Fri Nov 7 17:33:20 2008 -0500

fence: Fix bug in make_args()

A bug in make_args() caused it  to always return an error code,
even if we formulated a perfectly good set of arguments.

Basically, eventually ccs_get_list returns -1 when all items are
exhausted, so the check at the bottom of the function would free
any arguments we had (correctly) set up and return an error code,
thereby avoiding actually calling the agent.
---
 fence/libfence/agent.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fence/libfence/agent.c b/fence/libfence/agent.c
index 3454ec7..c04df17 100644
--- a/fence/libfence/agent.c
+++ b/fence/libfence/agent.c
@@ -128,7 +128,7 @@ static int make_args(int cd, char *victim, char *method, int d,
 				char *device, char **args_out)
 {
 	char path[256], *args, *str;
-	int error;
+	int error, cnt = 0;
 
 	args = malloc(MAX_AGENT_ARGS_LEN);
 	if (!args)
@@ -144,6 +144,7 @@ static int make_args(int cd, char *victim, char *method, int d,
 		error = ccs_get_list(cd, path, &str);
 		if (error || !str)
 			break;
+		++cnt;
 
 		if (!strncmp(str, "name=", 5)) {
 			free(str);
@@ -164,6 +165,7 @@ static int make_args(int cd, char *victim, char *method, int d,
 		error = ccs_get_list(cd, path, &str);
 		if (error || !str)
 			break;
+		++cnt;
 
 		if (!strncmp(str, "name=", 5)) {
 			free(str);
@@ -175,6 +177,8 @@ static int make_args(int cd, char *victim, char *method, int d,
 		free(str);
 	}
 
+	if (cnt)
+		error = 0;
 	if (error) {
 		free(args);
 		args = NULL;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]