diff options
author | Thomas Heller <theller@ctypes.org> | 2006-06-11 17:04:22 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2006-06-11 17:04:22 (GMT) |
commit | 0d5d222959e0422b93065f0661b06061b713e5af (patch) | |
tree | 59eb9620989736735059d4d7c1390dda393ed9ce /Modules | |
parent | 0e0c9f47403b382f72f9dffc5becb1641fa8da48 (diff) | |
download | cpython-0d5d222959e0422b93065f0661b06061b713e5af.zip cpython-0d5d222959e0422b93065f0661b06061b713e5af.tar.gz cpython-0d5d222959e0422b93065f0661b06061b713e5af.tar.bz2 |
Release the GIL during COM method calls, to avoid deadlocks in
Python coded COM objects.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 92a6c3c..c4942a0 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -804,14 +804,20 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk) 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 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk) 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); |