Skip to content

Commit d22906f

Browse files
committed
Update cffi patch
1 parent 3042033 commit d22906f

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

graalpython/lib-graalpython/patches/cffi/cffi-1.15.1.patch

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,48 @@ index 38bf3d5..9954f3b 100644
2929

3030
static PyObject *_cpyextfunc_type(LibObject *lib, struct CPyExtFunc_s *exf)
3131
diff --git a/c/misc_thread_common.h b/c/misc_thread_common.h
32-
index 66e2835..bc32b1b 100644
32+
index 66e2835..b48fd85 100644
3333
--- a/c/misc_thread_common.h
3434
+++ b/c/misc_thread_common.h
35-
@@ -329,6 +329,7 @@ static PyThreadState *get_current_ts(void)
35+
@@ -329,40 +329,7 @@ static PyThreadState *get_current_ts(void)
3636

3737
static PyGILState_STATE gil_ensure(void)
3838
{
39+
- /* Called at the start of a callback. Replacement for
40+
- PyGILState_Ensure().
41+
- */
42+
- PyGILState_STATE result;
43+
- PyThreadState *ts = PyGILState_GetThisThreadState();
44+
-
45+
- if (ts != NULL) {
46+
- ts->gilstate_counter++;
47+
- if (ts != get_current_ts()) {
48+
- /* common case: 'ts' is our non-current thread state and
49+
- we have to make it current and acquire the GIL */
50+
- PyEval_RestoreThread(ts);
51+
- return PyGILState_UNLOCKED;
52+
- }
53+
- else {
54+
- return PyGILState_LOCKED;
55+
- }
56+
- }
57+
- else {
58+
- /* no thread state here so far. */
59+
- result = PyGILState_Ensure();
60+
- assert(result == PyGILState_UNLOCKED);
61+
-
62+
- ts = PyGILState_GetThisThreadState();
63+
- assert(ts != NULL);
64+
- assert(ts == get_current_ts());
65+
- assert(ts->gilstate_counter >= 1);
66+
-
67+
- /* Use the ThreadCanary mechanism to keep 'ts' alive until the
68+
- thread really shuts down */
69+
- thread_canary_register(ts);
70+
-
71+
- return result;
72+
- }
3973
+ return PyGILState_Ensure();
40-
/* Called at the start of a callback. Replacement for
41-
PyGILState_Ensure().
42-
*/
74+
}
75+
76+
static void gil_release(PyGILState_STATE oldstate)

0 commit comments

Comments
 (0)