summaryrefslogtreecommitdiffstats
path: root/Modules/bz2module.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-10-27 17:49:21 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-10-27 17:49:21 (GMT)
commita3af0eb7a62932babfae681d6c1aca30269f5fb1 (patch)
treec769982bbcb632e293412a8de08399987dc9f49e /Modules/bz2module.c
parente02d1a0fd477e9f4009c693eaccf1f12c11f83fd (diff)
downloadcpython-a3af0eb7a62932babfae681d6c1aca30269f5fb1.zip
cpython-a3af0eb7a62932babfae681d6c1aca30269f5fb1.tar.gz
cpython-a3af0eb7a62932babfae681d6c1aca30269f5fb1.tar.bz2
Merged revisions 75820 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r75820 | antoine.pitrou | 2009-10-27 18:47:14 +0100 (mar., 27 oct. 2009) | 9 lines Merged revisions 75818 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r75818 | antoine.pitrou | 2009-10-27 18:41:58 +0100 (mar., 27 oct. 2009) | 3 lines Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once. ........ ................
Diffstat (limited to 'Modules/bz2module.c')
-rw-r--r--Modules/bz2module.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/bz2module.c b/Modules/bz2module.c
index 5f1d01b..550f1cf 100644
--- a/Modules/bz2module.c
+++ b/Modules/bz2module.c
@@ -78,7 +78,12 @@ typedef fpos_t Py_off_t;
#ifdef WITH_THREAD
-#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1)
+#define ACQUIRE_LOCK(obj) do { \
+ if (!PyThread_acquire_lock(obj->lock, 0)) { \
+ Py_BEGIN_ALLOW_THREADS \
+ PyThread_acquire_lock(obj->lock, 1); \
+ Py_END_ALLOW_THREADS \
+ } } while(0)
#define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock)
#else
#define ACQUIRE_LOCK(obj)