Index: Modules/zlibmodule.c =================================================================== --- Modules/zlibmodule.c (Revision 67923) +++ Modules/zlibmodule.c (Arbeitskopie) @@ -17,24 +17,15 @@ about re-entering zlib functions. N.B. - - Since ENTER_ZLIB and LEAVE_ZLIB only need to be called on functions - that modify the components of preexisting de/compress objects, it - could prove to be a performance gain on multiprocessor machines if - there was an de/compress object-specific lock. However, for the - moment the ENTER_ZLIB and LEAVE_ZLIB calls are global for ALL - de/compress objects. */ -static PyThread_type_lock zlib_lock = NULL; /* initialized on module load */ - #define ENTER_ZLIB \ Py_BEGIN_ALLOW_THREADS \ - PyThread_acquire_lock(zlib_lock, 1); \ + PyThread_acquire_lock(self->lock, 1); \ Py_END_ALLOW_THREADS #define LEAVE_ZLIB \ - PyThread_release_lock(zlib_lock); + PyThread_release_lock(self->lock); #else @@ -67,6 +58,9 @@ PyObject *unused_data; PyObject *unconsumed_tail; int is_initialised; + #ifdef WITH_THREAD + PyThread_type_lock lock; + #endif } compobject; static void @@ -106,6 +100,9 @@ Py_DECREF(self); return NULL; } + #ifdef WITH_THREAD + self->lock = PyThread_allocate_lock(); + #endif return self; } @@ -1096,8 +1093,5 @@ PyModule_AddStringConstant(m, "__version__", "1.0"); -#ifdef WITH_THREAD - zlib_lock = PyThread_allocate_lock(); -#endif /* WITH_THREAD */ return m; }