From f59494ba652f20d8bb83ace256ad965783a9bbf4 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Sun, 14 Oct 2012 12:08:25 -0700 Subject: 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 Reviewed-on: http://review.gluster.org/4085 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri --- libglusterfs/src/syncop.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 07823ccb1..471ae1e05 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; } -- cgit