summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2011-04-10 10:43:05 +0000
committerAnand Vishweshwaran Avati <avati@shell.gluster.com>2011-04-10 20:56:15 -0700
commitee96f768b99362ec724c8918d24028def065536a (patch)
treed3198b9df2ce418e856dad0b38730fb95817d4c3
parent6db2b422f05d0553d0a83af603ae4d176b41cbdf (diff)
libglusterfs/xlator: set THIS properly whenever some operation is done iteratively on more than one xlator in the graph.
Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand Vishweshwaran Avati <avati@shell.gluster.com> BUG: 2683 ([glusterfs-3.2.0qa8]: glusterfs client crashed in reconfigure) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2683
-rw-r--r--libglusterfs/src/xlator.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index b18641449ee..bb95e43a280 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -1297,7 +1297,8 @@ xlator_foreach (xlator_t *this,
void *data),
void *data)
{
- xlator_t *first = NULL;
+ xlator_t *first = NULL;
+ xlator_t *old_THIS = NULL;
if ((this == NULL) || (fn == NULL) || (data == NULL)) {
gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
@@ -1310,7 +1311,12 @@ xlator_foreach (xlator_t *this,
first = first->prev;
while (first) {
+ old_THIS = THIS;
+ THIS = first;
+
fn (first, data);
+
+ THIS = old_THIS;
first = first->next;
}
}
@@ -1399,7 +1405,8 @@ out:
static void
xlator_fini_rec (xlator_t *xl)
{
- xlator_list_t *trav = NULL;
+ xlator_list_t *trav = NULL;
+ xlator_t *old_THIS = NULL;
if (xl == NULL) {
gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
@@ -1420,7 +1427,12 @@ xlator_fini_rec (xlator_t *xl)
if (xl->init_succeeded) {
if (xl->fini) {
+ old_THIS = THIS;
+ THIS = xl;
+
xl->fini (xl);
+
+ THIS = old_THIS;
} else {
gf_log (xl->name, GF_LOG_DEBUG, "No fini() found");
}
@@ -1431,9 +1443,10 @@ xlator_fini_rec (xlator_t *xl)
static int
xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
{
- xlator_list_t *trav1 = NULL;
- xlator_list_t *trav2 = NULL;
- int32_t ret = 0;
+ xlator_list_t *trav1 = NULL;
+ xlator_list_t *trav2 = NULL;
+ int32_t ret = 0;
+ xlator_t *old_THIS = NULL;
if ((old_xl == NULL) || (new_xl == NULL)) {
gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
@@ -1455,12 +1468,18 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
}
if (old_xl->reconfigure) {
+ old_THIS = THIS;
+ THIS = old_xl;
+
ret = old_xl->reconfigure (old_xl, new_xl->options);
+
+ THIS = old_THIS;
+
if (ret)
goto out;
- }
- else
+ } else {
gf_log (old_xl->name, GF_LOG_DEBUG, "No reconfigure() found");
+ }
out:
return ret;