summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-helper.c2
-rw-r--r--xlators/cluster/dht/src/dht.c8
-rw-r--r--xlators/cluster/dht/src/switch.c37
-rw-r--r--xlators/cluster/stripe/src/stripe-helpers.c11
4 files changed, 42 insertions, 16 deletions
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 920a7aabc50..611de19e48e 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -80,7 +80,7 @@ dht_filter_loc_subvol_key (xlator_t *this, loc_t *loc, loc_t *new_loc,
int ret = 0; /* not found */
/* Why do other tasks if first required 'char' itself is not there */
- if (!loc->name || !strchr (loc->name, '@'))
+ if (!new_loc || !loc || !loc->name || !strchr (loc->name, '@'))
goto out;
trav = this->children;
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index c25cdb4fd80..c5128544279 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -391,6 +391,8 @@ init (xlator_t *this)
defrag->is_exiting = 0;
+ conf->defrag = defrag;
+
ret = dict_get_str (this->options, "node-uuid", &node_uuid);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "node-uuid not "
@@ -407,9 +409,6 @@ init (xlator_t *this)
defrag->cmd = cmd;
defrag->stats = _gf_false;
-
- conf->defrag = defrag;
-
}
conf->search_unhashed = GF_DHT_LOOKUP_UNHASHED_ON;
@@ -493,6 +492,9 @@ err:
if (conf->du_stats)
GF_FREE (conf->du_stats);
+ if (conf->defrag)
+ GF_FREE (conf->defrag);
+
GF_FREE (conf);
}
diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c
index fe75914f247..ab261da870f 100644
--- a/xlators/cluster/dht/src/switch.c
+++ b/xlators/cluster/dht/src/switch.c
@@ -67,29 +67,38 @@ get_switch_matching_subvol (const char *path, dht_conf_t *conf,
struct switch_struct *cond = NULL;
struct switch_struct *trav = NULL;
char *pathname = NULL;
- int idx = 0;
+ int idx = 0;
+ xlator_t *subvol = NULL;
cond = conf->private;
+ subvol = hashed_subvol;
if (!cond)
- return hashed_subvol;
+ goto out;
- trav = cond;
pathname = gf_strdup (path);
+ if (!pathname)
+ goto out;
+
+ trav = cond;
while (trav) {
if (fnmatch (trav->path_pattern,
pathname, FNM_NOESCAPE) == 0) {
for (idx = 0; idx < trav->num_child; idx++) {
if (trav->array[idx].xl == hashed_subvol)
- return hashed_subvol;
+ goto out;
}
idx = trav->node_index++;
trav->node_index %= trav->num_child;
- return trav->array[idx].xl;
+ subvol = trav->array[idx].xl;
+ goto out;
}
trav = trav->next;
}
- GF_FREE (pathname);
- return hashed_subvol;
+out:
+ if (pathname)
+ GF_FREE (pathname);
+
+ return subvol;
}
@@ -663,8 +672,10 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
dup_str = gf_strdup (switch_str);
switch_opt = GF_CALLOC (1, sizeof (struct switch_struct),
gf_switch_mt_switch_struct);
- if (!switch_opt)
+ if (!switch_opt) {
+ GF_FREE (dup_str);
goto err;
+ }
pattern = strtok_r (dup_str, ":", &tmp_str1);
childs = strtok_r (NULL, ":", &tmp_str1);
@@ -674,6 +685,7 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"for all the unconfigured child nodes,"
" hence neglecting current option");
switch_str = strtok_r (NULL, ";", &tmp_str);
+ GF_FREE (switch_opt);
GF_FREE (dup_str);
continue;
}
@@ -746,6 +758,7 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
/* First entry */
switch_buf = switch_opt;
}
+ switch_opt = NULL;
switch_str = strtok_r (NULL, ";", &tmp_str);
}
@@ -802,15 +815,19 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
/* First entry */
switch_buf = switch_opt;
}
+ switch_opt = NULL;
}
/* */
conf->private = switch_buf;
return 0;
err:
+ if (switch_buf_array)
+ GF_FREE (switch_buf_array);
+ if (switch_opt)
+ GF_FREE (switch_opt);
+
if (switch_buf) {
- if (switch_buf_array)
- GF_FREE (switch_buf_array);
trav = switch_buf;
while (trav) {
if (trav->array)
diff --git a/xlators/cluster/stripe/src/stripe-helpers.c b/xlators/cluster/stripe/src/stripe-helpers.c
index a2ebc1201f7..1821832c20e 100644
--- a/xlators/cluster/stripe/src/stripe-helpers.c
+++ b/xlators/cluster/stripe/src/stripe-helpers.c
@@ -471,12 +471,16 @@ set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data)
temp_stripeopt = NULL;
else
temp_stripeopt = priv->pattern;
- priv->pattern = stripe_opt;
+
stripe_opt->next = temp_stripeopt;
- stripe_str = strtok_r (NULL, ",", &tmp_str);
+ priv->pattern = stripe_opt;
+ stripe_opt = NULL;
+
GF_FREE (dup_str);
dup_str = NULL;
+
+ stripe_str = strtok_r (NULL, ",", &tmp_str);
}
ret = 0;
@@ -485,6 +489,9 @@ out:
if (dup_str)
GF_FREE (dup_str);
+ if (stripe_opt)
+ GF_FREE (stripe_opt);
+
return ret;
}