summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-08-12 03:26:39 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-12 02:38:56 -0700
commite98ebc1da4f49fba2bcaaf3212b00058e615cf29 (patch)
tree5dde47fdd3651961d2471a7801f4aa474453b486 /xlators/mgmt/glusterd/src/glusterd-store.c
parenta6a2e3a86c0d4c0873e822a38769677df2050f11 (diff)
glusterd: Fixes for detach
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1215 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1215
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 6466f9e7f1a..317f65e7975 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1014,6 +1014,58 @@ out:
}
int32_t
+glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo)
+{
+ int32_t ret = -1;
+ glusterd_conf_t *priv = NULL;
+ char peerdir[PATH_MAX] = {0,};
+ char filepath[PATH_MAX] = {0,};
+ char str[512] = {0,};
+ char hostname_path[PATH_MAX] = {0,};
+
+
+ if (!peerinfo) {
+ ret = 0;
+ goto out;
+ }
+
+ priv = THIS->private;
+
+ snprintf (peerdir, PATH_MAX, "%s/peers", priv->workdir);
+
+
+ if (uuid_is_null (peerinfo->uuid)) {
+
+ if (peerinfo->hostname) {
+ snprintf (filepath, PATH_MAX, "%s/%s", peerdir,
+ peerinfo->hostname);
+ } else {
+ ret = 0;
+ goto out;
+ }
+ } else {
+ uuid_unparse (peerinfo->uuid, str);
+
+ snprintf (filepath, PATH_MAX, "%s/%s", peerdir, str);
+ snprintf (hostname_path, PATH_MAX, "%s/%s",
+ peerdir, peerinfo->hostname);
+
+ ret = unlink (hostname_path);
+
+ if (!ret)
+ goto out;
+ }
+
+ ret = unlink (filepath);
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+
+ return ret;
+}
+
+
+int32_t
glusterd_store_update_peerinfo (glusterd_peerinfo_t *peerinfo)
{
int32_t ret = -1;
@@ -1027,7 +1079,11 @@ glusterd_store_update_peerinfo (glusterd_peerinfo_t *peerinfo)
int i = 0;
char hostname_path[PATH_MAX] = {0,};
- GF_ASSERT (peerinfo);
+
+ if (!peerinfo) {
+ ret = 0;
+ goto out;
+ }
priv = THIS->private;
@@ -1189,6 +1245,8 @@ glusterd_store_retrieve_peers (xlator_t *this)
}
out:
+ if (dir)
+ closedir (dir);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;