Skip to content

Commit ae1d0a4

Browse files
author
Anselm Kruis
committed
Issue python#120: Correctly grab the head_mutex, fix grafting error
This commit fixes a regression introduced by commit fc13eecdd0ad. When I grafted the patch for this issue from branch 2.7-slp (1fb75d58a), I forgot to remove a 2.7-slp only part of the code. In effect, this change reapplies commit b8a8122bbb91. https://bitbucket.org/stackless-dev/stackless/issues/120
1 parent aa9559b commit ae1d0a4

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

Stackless/core/stacklesseval.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ void slp_kill_tasks_with_stacks(PyThreadState *target_ts)
619619
*/
620620
if (target_ts == NULL && tasklet_list) {
621621
PyThreadState *ts;
622-
PyObject *threadid_list = NULL;
623622
count = 0;
624623

625624
/* build a list of tasklets to be killed */
@@ -636,30 +635,9 @@ void slp_kill_tasks_with_stacks(PyThreadState *target_ts)
636635
}
637636
SLP_HEAD_UNLOCK();
638637

639-
/* get the list of thread ids */
640-
if (PyExc_TaskletExit)
641-
threadid_list = slp_getthreads(Py_None); /* requires the HEAD lock */
642-
643638
/* kill the tasklets */
644639
kill_pending(tasklet_list);
645-
/* kill the threads */
646-
if (threadid_list != NULL) {
647-
Py_ssize_t i, len;
648-
assert(PyList_CheckExact(threadid_list));
649-
len = PyList_GET_SIZE(threadid_list);
650-
for (i=0; i < len; i++) {
651-
long thread_id;
652-
PyObject *item = PyList_GET_ITEM(threadid_list, i);
653-
assert(PyLong_CheckExact(item));
654-
thread_id = PyLong_AsLong(item);
655-
if (thread_id != cts->thread_id) {
656-
/* requires the HEAD lock */
657-
PyThreadState_SetAsyncExc(thread_id, PyExc_TaskletExit);
658-
PyErr_Clear();
659-
}
660-
}
661-
Py_DECREF(threadid_list);
662-
}
640+
663641
/* We must not release the GIL while we might hold the HEAD-lock.
664642
* Otherwise another thread (usually the thread of the killed tasklet)
665643
* could try to get the HEAD lock. The result would be a wonderful dead lock.

0 commit comments

Comments
 (0)