diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-01 12:05:48 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-01 12:05:48 (GMT) |
commit | 5800b271043d52d34f22f68ad6c0339d2c4bc04a (patch) | |
tree | 50bf892dcb9012c04b226ec5417ff0b8cd569aae /Modules/_io/bufferedio.c | |
parent | b6b8b513c5662b3c8080edd4170e6da15cbfd64d (diff) | |
download | cpython-5800b271043d52d34f22f68ad6c0339d2c4bc04a.zip cpython-5800b271043d52d34f22f68ad6c0339d2c4bc04a.tar.gz cpython-5800b271043d52d34f22f68ad6c0339d2c4bc04a.tar.bz2 |
Merged revisions 76007 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76007 | antoine.pitrou | 2009-11-01 12:58:22 +0100 (dim., 01 nov. 2009) | 3 lines
Buffered I/O: optimize lock taking in the common non-contended case.
........
Diffstat (limited to 'Modules/_io/bufferedio.c')
-rw-r--r-- | Modules/_io/bufferedio.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 3dec67b..dd4e53f 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -260,9 +260,11 @@ typedef struct { #ifdef WITH_THREAD #define ENTER_BUFFERED(self) \ - Py_BEGIN_ALLOW_THREADS \ - PyThread_acquire_lock(self->lock, 1); \ - Py_END_ALLOW_THREADS + if (!PyThread_acquire_lock(self->lock, 0)) { \ + Py_BEGIN_ALLOW_THREADS \ + PyThread_acquire_lock(self->lock, 1); \ + Py_END_ALLOW_THREADS \ + } #define LEAVE_BUFFERED(self) \ PyThread_release_lock(self->lock); |