[Python-checkins] r46862 - python/trunk/Modules/_ctypes/callproc.c

thomas.heller python-checkins at python.org
Sun Jun 11 19:04:24 CEST 2006


Author: thomas.heller
Date: Sun Jun 11 19:04:22 2006
New Revision: 46862

Modified:
   python/trunk/Modules/_ctypes/callproc.c
Log:
Release the GIL during COM method calls, to avoid deadlocks in
Python coded COM objects.

Modified: python/trunk/Modules/_ctypes/callproc.c
==============================================================================
--- python/trunk/Modules/_ctypes/callproc.c	(original)
+++ python/trunk/Modules/_ctypes/callproc.c	Sun Jun 11 19:04:22 2006
@@ -804,14 +804,20 @@
 	PyObject *obj;
 	TCHAR *text;
 
+	/* We absolutely have to release the GIL during COM method calls,
+	   otherwise we may get a deadlock!
+	*/
+	Py_BEGIN_ALLOW_THREADS
+
 	hr = pIunk->lpVtbl->QueryInterface(pIunk, &IID_ISupportErrorInfo, (void **)&psei);
 	if (FAILED(hr))
 		goto failed;
+
 	hr = psei->lpVtbl->InterfaceSupportsErrorInfo(psei, riid);
 	psei->lpVtbl->Release(psei);
-
 	if (FAILED(hr))
 		goto failed;
+
 	hr = GetErrorInfo(0, &pei);
 	if (hr != S_OK)
 		goto failed;
@@ -822,9 +828,10 @@
 	pei->lpVtbl->GetHelpFile(pei, &helpfile);
 	pei->lpVtbl->GetSource(pei, &source);
 
+	pei->lpVtbl->Release(pei);
+
   failed:
-	if (pei)
-		pei->lpVtbl->Release(pei);
+	Py_END_ALLOW_THREADS
 
 	progid = NULL;
 	ProgIDFromCLSID(&guid, &progid);


More information about the Python-checkins mailing list