summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-08-10 05:55:49 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-11 23:46:36 -0700
commitced85cce0700d702640c66829a72822e430f1cca (patch)
tree95ee1cbb3fb638bb51319b6e6c70424b594e5d21 /xlators/mgmt
parentb0f54a49164a1c618b9e207349bd96705b44dfa6 (diff)
glusterd: Remove incorrect check for open fd during store ops.
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1321 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1321
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 592c52c341b..6ca2f3661cb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -141,6 +141,9 @@ glusterd_store_create_brick (glusterd_volinfo_t *volinfo,
ret = 0;
out:
+ if (fd > 0) {
+ close (fd);
+ }
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
}
@@ -442,8 +445,10 @@ glusterd_store_retrieve_value (glusterd_store_handle_t *handle,
if (EOF == ret)
ret = -1;
out:
- if (handle->fd >= 0)
+ if (handle->fd > 0) {
close (handle->fd);
+ handle->read = NULL;
+ }
return ret;
}
@@ -456,12 +461,18 @@ glusterd_store_save_value (glusterd_store_handle_t *handle,
char buf[4096] = {0,};
GF_ASSERT (handle);
- GF_ASSERT (handle->fd > 0);
GF_ASSERT (key);
GF_ASSERT (value);
- if (!handle->write)
- handle->write = fdopen (handle->fd, "a+");
+ handle->fd = open (handle->path, O_RDWR | O_APPEND);
+
+ if (handle->fd < 0) {
+ gf_log ("", GF_LOG_ERROR, "Unable to open %s, errno: %d",
+ handle->path, errno);
+ goto out;
+ }
+
+ handle->write = fdopen (handle->fd, "a+");
if (!handle->write) {
gf_log ("", GF_LOG_ERROR, "Unable to open file %s errno: %d",
@@ -485,6 +496,12 @@ glusterd_store_save_value (glusterd_store_handle_t *handle,
out:
+ if (handle->fd > 0) {
+ close (handle->fd);
+ handle->write = NULL;
+ handle->fd = -1;
+ }
+
gf_log ("", GF_LOG_DEBUG, "returning: %d", ret);
return ret;
}
@@ -517,8 +534,12 @@ out:
if (shandle) {
if (shandle->path)
GF_FREE (shandle->path);
+ if (shandle->fd > 0)
+ close (shandle->fd);
GF_FREE (shandle);
}
+ } else {
+ close (shandle->fd);
}
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
@@ -660,7 +681,6 @@ glusterd_store_iter_new (glusterd_store_handle_t *shandle,
int fd = -1;
GF_ASSERT (shandle);
- GF_ASSERT (shandle->fd > 0);
GF_ASSERT (iter);
tmp_iter = GF_CALLOC (1, sizeof (*tmp_iter),