diff options
author | Csaba Henk <csaba@gluster.com> | 2011-03-31 11:59:52 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2011-04-01 11:19:17 -0700 |
commit | f007eb1a0701cd3e13e6ba67208cd1db9325a370 (patch) | |
tree | 6d9ba72988a989f2b6e5e061d5f08669ccd95451 | |
parent | 913da6c337cfe342d60f3773057a14d645248421 (diff) |
syncdaemon; adding corresponding pcloses to gsyncd invocation via popen
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 2427 (set a proper default for remote syncdaemon)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2427
-rw-r--r-- | cli/src/cli-rpc-ops.c | 18 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 18 |
2 files changed, 20 insertions, 16 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 17d82a0074a..6d47374a0c1 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -2610,6 +2610,7 @@ gf_cli3_1_gsync_get_pid_file (char *pidfolder, char *pidfile, char *master, char char cmd[PATH_MAX] = {0, }; char *ptr = NULL; char buffer[PATH_MAX] = {0, }; + int ret = 0; snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --canonicalize-escape-url" " %s %s", master, slave); @@ -2623,10 +2624,9 @@ gf_cli3_1_gsync_get_pid_file (char *pidfolder, char *pidfile, char *master, char buff[strlen(buff)-1]='\0'; //strip off \n snprintf (buffer, PATH_MAX, "%s/gsync/%s", gl_workdir, buff); strncpy (pidfolder, buffer, PATH_MAX); - } - else { - gf_log ("", GF_LOG_ERROR, "popen failed"); - return -1; + } else { + ret = -1; + goto out; } memset (buff, 0, PATH_MAX); @@ -2638,12 +2638,14 @@ gf_cli3_1_gsync_get_pid_file (char *pidfolder, char *pidfile, char *master, char snprintf (buffer, PATH_MAX, "%s/%s.pid", pidfolder, buff); strncpy (pidfile, buffer, PATH_MAX); } - else { + + out: + ret |= pclose (in); + + if (ret) gf_log ("", GF_LOG_ERROR, "popen failed"); - return -1; - } - return 0; + return ret ? -1 : 0; } /* status: 0 when gsync is running diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 849ee5314bf..f8e043e46d6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1704,6 +1704,7 @@ glusterd_gsync_get_pid_file (char *pidfile, char *master, char *slave) char buffer[PATH_MAX] = {0, }; char pidfolder[PATH_MAX] = {0, }; glusterd_conf_t *priv = NULL; + int ret = 0; GF_ASSERT (THIS); @@ -1721,10 +1722,9 @@ glusterd_gsync_get_pid_file (char *pidfile, char *master, char *slave) buff[strlen(buff)-1]='\0'; //strip off \n snprintf (buffer, PATH_MAX, "%s/gsync/%s", priv->workdir, buff); strncpy (pidfolder, buffer, PATH_MAX); - } - else { - gf_log ("", GF_LOG_ERROR, "popen failed"); - return -1; + } else { + ret = -1; + goto out; } memset (buff, 0, PATH_MAX); @@ -1736,12 +1736,14 @@ glusterd_gsync_get_pid_file (char *pidfile, char *master, char *slave) snprintf (buffer, PATH_MAX, "%s/%s.pid", pidfolder, buff); strncpy (pidfile, buffer, PATH_MAX); } - else { + + out: + ret |= pclose (in); + + if (ret) gf_log ("", GF_LOG_ERROR, "popen failed"); - return -1; - } - return 0; + return ret ? -1 : 0; } /* status: return 0 when gsync is running |