summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-04-24 16:36:52 +0530
committerAnand Avati <avati@redhat.com>2012-04-24 13:32:00 -0700
commit4a0f5e49f85f88912cc9c73b379403ead82e4912 (patch)
treef00bf7460d949b0507d9b053dd04bcf11cc36398
parent2a59514236630756dc996e08b50f539ccc2d3ff0 (diff)
glusterd: command check failure fixes
due to the patch 29f2de478cc6a475e6ae760d9cbe7ac847e9d79c (coverity issues fix), geo-replications assumption of anything other than -2 is valid error (ie, expected error), was broken, which resulted in staging failure of all geo-replication commands. now fixed!!! Change-Id: I26c3574e966dd8ba89ef423a3ad17aa863a62c13 Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 815613 Reviewed-on: http://review.gluster.com/3219 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--libglusterfs/src/syscall.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c23
2 files changed, 20 insertions, 10 deletions
diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c
index 8e2d56b8d63..6be240599fb 100644
--- a/libglusterfs/src/syscall.c
+++ b/libglusterfs/src/syscall.c
@@ -241,7 +241,12 @@ sys_statvfs (const char *path, struct statvfs *buf)
int
sys_close (int fd)
{
- return close (fd);
+ int ret = -1;
+
+ if (fd >= 0)
+ ret = close (fd);
+
+ return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 3c268a6acce..73496a595f5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -31,6 +31,7 @@
#include "glusterd-utils.h"
#include "glusterd-volgen.h"
#include "run.h"
+#include "syscall.h"
#include <signal.h>
@@ -524,12 +525,13 @@ gsync_status (char *master, char *slave, int *status)
int fd = -1;
fd = gsyncd_getpidfile (master, slave, pidfile);
- if ((fd == -2) || (fd == -1))
+ if (fd == -2)
return -1;
*status = gsync_status_byfd (fd);
- close (fd);
+ sys_close (fd);
+
return 0;
}
@@ -1118,7 +1120,7 @@ stop_gsync (char *master, char *slave, char **msg)
GF_ASSERT (THIS->private);
pfd = gsyncd_getpidfile (master, slave, pidfile);
- if ((pfd == -2) || (pfd == -1)) {
+ if (pfd == -2) {
gf_log ("", GF_LOG_ERROR, GEOREP" stop validation "
" failed for %s & %s", master, slave);
ret = -1;
@@ -1134,6 +1136,9 @@ stop_gsync (char *master, char *slave, char **msg)
goto out;
}
+ if (pfd < 0)
+ goto out;
+
ret = read (pfd, buf, 1024);
if (ret > 0) {
pid = strtol (buf, NULL, 10);
@@ -1160,8 +1165,7 @@ stop_gsync (char *master, char *slave, char **msg)
ret = 0;
out:
- if ((pfd != -2) && (pfd != -1))
- close (pfd);
+ sys_close (pfd);
return ret;
}
@@ -1652,8 +1656,7 @@ glusterd_get_pid_from_file (char *master, char *slave, pid_t *pid)
char buff[1024] = {0,};
pfd = gsyncd_getpidfile (master, slave, pidfile);
-
- if ((pfd == -2) || (pfd == -1)) {
+ if (pfd == -2) {
gf_log ("", GF_LOG_ERROR, GEOREP" log-rotate validation "
" failed for %s & %s", master, slave);
goto out;
@@ -1664,6 +1667,9 @@ glusterd_get_pid_from_file (char *master, char *slave, pid_t *pid)
goto out;
}
+ if (pfd < 0)
+ goto out;
+
ret = read (pfd, buff, 1024);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, GEOREP" cannot read pid from pid-file");
@@ -1675,8 +1681,7 @@ glusterd_get_pid_from_file (char *master, char *slave, pid_t *pid)
ret = 0;
out:
- if ((pfd != -2) && (pfd != -1))
- close(pfd);
+ sys_close(pfd);
return ret;
}