summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/syncop.c
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-10-14 12:08:25 -0700
committerAnand Avati <avati@redhat.com>2012-10-16 14:24:13 -0700
commitf59494ba652f20d8bb83ace256ad965783a9bbf4 (patch)
tree15a871513bb9cddb5c2153e2317c0c608650ad6c /libglusterfs/src/syncop.c
parentbccb4b7a63eaa5e32b34c90dfdd5efa5c99b546a (diff)
syncop: save and restore THIS from the time of context switch
The current yield() code assumes that the point of yielding is always in the translator where the synctask was created. This can be a problem for nested syncops and/or where syncop is issued by a different translator. So, save the THIS pointer just before swapcontext() and restore it right after resuming. Change-Id: I86aad2329ccbc3ac1f04fbec3835136ff3fa79fb BUG: 862838 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/4085 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'libglusterfs/src/syncop.c')
-rw-r--r--libglusterfs/src/syncop.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 07823ccb133..471ae1e05ef 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -82,6 +82,8 @@ __wait (struct synctask *task)
void
synctask_yield (struct synctask *task)
{
+ xlator_t *oldTHIS = THIS;
+
#if defined(__NetBSD__) && defined(_UC_TLSBASE)
/* Preserve pthread private pointer through swapcontex() */
task->proc->sched.uc_flags &= ~_UC_TLSBASE;
@@ -91,6 +93,8 @@ synctask_yield (struct synctask *task)
gf_log ("syncop", GF_LOG_ERROR,
"swapcontext failed (%s)", strerror (errno));
}
+
+ THIS = oldTHIS;
}