You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/05/20 16:07:01 UTC

[5/6] lucy-clownfish git commit: Fix Perl interpreter destruction

Fix Perl interpreter destruction

On some platforms or Perl versions, it seems that only the current
interpreter can be safely destroyed with perl_destruct.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/ca0625ed
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/ca0625ed
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/ca0625ed

Branch: refs/heads/master
Commit: ca0625ed68501f03609db582cba973effebe19d9
Parents: 9d1d2d6
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed May 20 13:38:53 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 20 14:33:36 2015 +0200

----------------------------------------------------------------------
 runtime/perl/xs/XSBind.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ca0625ed/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/runtime/perl/xs/XSBind.c b/runtime/perl/xs/XSBind.c
index 26a5f45..7640e5c 100644
--- a/runtime/perl/xs/XSBind.c
+++ b/runtime/perl/xs/XSBind.c
@@ -1060,9 +1060,21 @@ cfish_TestUtils_set_host_runtime(void *runtime) {
 
 void
 cfish_TestUtils_destroy_host_runtime(void *runtime) {
-    PerlInterpreter *interp = (PerlInterpreter*)runtime;
+    PerlInterpreter *current = (PerlInterpreter*)PERL_GET_CONTEXT;
+    PerlInterpreter *interp  = (PerlInterpreter*)runtime;
+
+    // Switch to the interpreter before destroying it. Required on some
+    // platforms.
+    if (current != interp) {
+        PERL_SET_CONTEXT(interp);
+    }
+
     perl_destruct(interp);
     perl_free(interp);
+
+    if (current != interp) {
+        PERL_SET_CONTEXT(current);
+    }
 }
 
 #else /* CFISH_NOTHREADS */