Author: Armin Rigo <[email protected]>
Branch: ec-keepalive
Changeset: r81562:19692a864891
Date: 2016-01-05 00:38 +0100
http://bitbucket.org/pypy/pypy/changeset/19692a864891/

Log:    Explicitly disable automatic_keepalive() in one case

diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -407,9 +407,12 @@
     def automatic_keepalive(config):
         """Returns True if translated with a GC that keeps alive
         the set() value until the end of the thread.  Returns False
-        if you need to keep it alive yourself.
+        if you need to keep it alive yourself (but in that case, you
+        should also reset it to None before the thread finishes).
         """
-        return config.translation.gctransformer == "framework"
+        return (config.translation.gctransformer == "framework" and
+                # see translator/c/src/threadlocal.c for the following line
+                (not _win32 or config.translation.shared))
 
 
 tlfield_thread_ident = ThreadLocalField(lltype.Signed, "thread_ident",
@@ -418,7 +421,8 @@
                                    loop_invariant=True)
 tlfield_rpy_errno = ThreadLocalField(rffi.INT, "rpy_errno")
 tlfield_alt_errno = ThreadLocalField(rffi.INT, "alt_errno")
-if sys.platform == "win32":
+_win32 = (sys.platform == "win32")
+if _win32:
     from rpython.rlib import rwin32
     tlfield_rpy_lasterror = ThreadLocalField(rwin32.DWORD, "rpy_lasterror")
     tlfield_alt_lasterror = ThreadLocalField(rwin32.DWORD, "alt_lasterror")
diff --git a/rpython/translator/c/src/threadlocal.c 
b/rpython/translator/c/src/threadlocal.c
--- a/rpython/translator/c/src/threadlocal.c
+++ b/rpython/translator/c/src/threadlocal.c
@@ -77,7 +77,10 @@
    There are some alternatives known, but they are horrible in other
    ways (e.g. using undocumented behavior).  This seems to be the
    simplest, but feel free to fix if you need that.
- */
+
+   For this reason we have the line 'not _win32 or config.translation.shared'
+   in rpython.rlib.rthread.
+*/
 BOOL WINAPI DllMain(HINSTANCE hinstDLL,
                     DWORD     reason_for_call,
                     LPVOID    reserved)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to