A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-checkins/2000-September/013246.html below:

[Python-checkins] CVS: python/dist/src/Python pystate.c,2.14,2.15

[Python-checkins] CVS: python/dist/src/Python pystate.c,2.14,2.15Tim Peters python-dev@python.org
Sat, 2 Sep 2000 02:16:18 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv4353/python/dist/src/Python

Modified Files:
	pystate.c 
Log Message:
PyInterpreterState_New is not thread-safe, and the recent fix to _PyPclose
can cause it to get called by multiple threads simultaneously.

Ditto for PyInterpreterState_Delete.

Of the former, the docs say "The interpreter lock need not be held, but may
be held if it is necessary to serialize calls to this function".  This
kinda implies it both is and isn't thread-safe.

Of the latter, the docs merely say "The interpreter lock need not be
held.", and the clause about serializing is absent.

I expect it was *believed* these are both thread-safe, and the bit about
serializing via the global lock was meant as a permission rather than a
caution.

I also expect we've never seen a problem here because the Python core
(prior to the _PyPclose fix) only calls these functions once per run.
The Py_NewInterpreter subsystem exposed by the C API (but not used by
Python itself) also calls them, but that subsystem appears to be very
rarely used.

Whatever, they're both thread-safe now.


Index: pystate.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pystate.c,v
retrieving revision 2.14
retrieving revision 2.15
diff -C2 -r2.14 -r2.15
*** pystate.c	2000/09/01 23:29:28	2.14
--- pystate.c	2000/09/02 09:16:15	2.15
***************
*** 41,46 ****
--- 41,48 ----
  		interp->tstate_head = NULL;
  
+ 		HEAD_LOCK();
  		interp->next = interp_head;
  		interp_head = interp;
+ 		HEAD_UNLOCK();
  	}
  
***************
*** 80,83 ****
--- 82,86 ----
  	PyInterpreterState **p;
  	zapthreads(interp);
+ 	HEAD_LOCK();
  	for (p = &interp_head; ; p = &(*p)->next) {
  		if (*p == NULL)
***************
*** 90,93 ****
--- 93,97 ----
  		Py_FatalError("PyInterpreterState_Delete: remaining threads");
  	*p = interp->next;
+ 	HEAD_UNLOCK();
  	PyMem_DEL(interp);
  }




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4