@@ -198,7 +198,7 @@ Greenlet::g_switchstack(void)
198198
199199 // No stack-based variables are valid anymore.
200200
201- // But the global is volatile so we can reload it without the
201+ // But the global is thread_local volatile so we can reload it without the
202202 // compiler caching it from earlier.
203203 Greenlet* greenlet_that_switched_in = switching_thread_state; // aka this
204204 switching_thread_state = nullptr ;
@@ -234,14 +234,14 @@ Greenlet::check_switch_allowed() const
234234 // TODO: Give the objects an API to determine if they belong
235235 // to a dead thread.
236236
237- const BorrowedMainGreenlet main_greenlet = this ->find_main_greenlet_in_lineage ();
237+ const BorrowedMainGreenlet my_main_greenlet = this ->find_main_greenlet_in_lineage ();
238238
239- if (!main_greenlet ) {
239+ if (!my_main_greenlet ) {
240240 throw PyErrOccurred (mod_globs->PyExc_GreenletError ,
241241 " cannot switch to a garbage collected greenlet" );
242242 }
243243
244- if (!main_greenlet ->thread_state ()) {
244+ if (!my_main_greenlet ->thread_state ()) {
245245 throw PyErrOccurred (mod_globs->PyExc_GreenletError ,
246246 " cannot switch to a different thread (which happens to have exited)" );
247247 }
@@ -255,26 +255,26 @@ Greenlet::check_switch_allowed() const
255255 // may not be visible yet. So we need to check against the
256256 // current thread state (once the cheaper checks are out of
257257 // the way)
258- const BorrowedMainGreenlet current_main_greenlet = GET_THREAD_STATE ().state ().borrow_main_greenlet ();
258+ const BorrowedMainGreenlet main_greenlet_cur_thread = GET_THREAD_STATE ().state ().borrow_main_greenlet ();
259259 if (
260260 // lineage main greenlet is not this thread's greenlet
261- current_main_greenlet != main_greenlet
261+ main_greenlet_cur_thread != my_main_greenlet
262262 || (
263263 // atteched to some thread
264264 this ->main_greenlet ()
265265 // XXX: Same condition as above. Was this supposed to be
266266 // this->main_greenlet()?
267- && current_main_greenlet != main_greenlet )
267+ && main_greenlet_cur_thread != my_main_greenlet )
268268 // switching into a known dead thread (XXX: which, if we get here,
269269 // is bad, because we just accessed the thread state, which is
270270 // gone!)
271- || (!current_main_greenlet ->thread_state ())) {
271+ || (!main_greenlet_cur_thread ->thread_state ())) {
272272 // CAUTION: This may trigger memory allocations, gc, and
273273 // arbitrary Python code.
274274 throw PyErrOccurred (
275275 mod_globs->PyExc_GreenletError ,
276276 " Cannot switch to a different thread\n\t Current: %R\n\t Expected: %R" ,
277- current_main_greenlet, main_greenlet );
277+ main_greenlet_cur_thread, my_main_greenlet );
278278 }
279279}
280280
0 commit comments