Commit eeb51a99 authored by Gregory P. Smith's avatar Gregory P. Smith

cleanup applied patch to match style that is already in py3k branch.

parent d02eedac
...@@ -20,18 +20,15 @@ ...@@ -20,18 +20,15 @@
#ifdef WITH_THREAD #ifdef WITH_THREAD
#include "pythread.h" #include "pythread.h"
#define ENTER_HASHLIB(obj) \ #define ENTER_HASHLIB(obj) \
if ((obj)->lock) \ if ((obj)->lock) { \
{ \ if (!PyThread_acquire_lock((obj)->lock, 0)) { \
if (!PyThread_acquire_lock((obj)->lock, 0)) \
{ \
Py_BEGIN_ALLOW_THREADS \ Py_BEGIN_ALLOW_THREADS \
PyThread_acquire_lock((obj)->lock, 1); \ PyThread_acquire_lock((obj)->lock, 1); \
Py_END_ALLOW_THREADS \ Py_END_ALLOW_THREADS \
} \ } \
} }
#define LEAVE_HASHLIB(obj) \ #define LEAVE_HASHLIB(obj) \
if ((obj)->lock) \ if ((obj)->lock) { \
{ \
PyThread_release_lock((obj)->lock); \ PyThread_release_lock((obj)->lock); \
} }
#else #else
...@@ -230,14 +227,12 @@ EVP_update(EVPobject *self, PyObject *args) ...@@ -230,14 +227,12 @@ EVP_update(EVPobject *self, PyObject *args)
GET_BUFFER_VIEW_OR_ERROUT(obj, &view, NULL); GET_BUFFER_VIEW_OR_ERROUT(obj, &view, NULL);
#ifdef WITH_THREAD #ifdef WITH_THREAD
if (self->lock == NULL && view.len >= HASHLIB_GIL_MINSIZE) if (self->lock == NULL && view.len >= HASHLIB_GIL_MINSIZE) {
{
self->lock = PyThread_allocate_lock(); self->lock = PyThread_allocate_lock();
/* fail? lock = NULL and we fail over to non-threaded code. */ /* fail? lock = NULL and we fail over to non-threaded code. */
} }
if (self->lock != NULL) if (self->lock != NULL) {
{
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
PyThread_acquire_lock(self->lock, 1); PyThread_acquire_lock(self->lock, 1);
EVP_hash(self, view.buf, view.len); EVP_hash(self, view.buf, view.len);
...@@ -352,8 +347,7 @@ EVP_tp_init(EVPobject *self, PyObject *args, PyObject *kwds) ...@@ -352,8 +347,7 @@ EVP_tp_init(EVPobject *self, PyObject *args, PyObject *kwds)
Py_INCREF(self->name); Py_INCREF(self->name);
if (data_obj) { if (data_obj) {
if (view.len >= HASHLIB_GIL_MINSIZE) if (view.len >= HASHLIB_GIL_MINSIZE) {
{
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
EVP_hash(self, view.buf, view.len); EVP_hash(self, view.buf, view.len);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
...@@ -450,8 +444,7 @@ EVPnew(PyObject *name_obj, ...@@ -450,8 +444,7 @@ EVPnew(PyObject *name_obj,
} }
if (cp && len) { if (cp && len) {
if (len >= HASHLIB_GIL_MINSIZE) if (len >= HASHLIB_GIL_MINSIZE) {
{
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
EVP_hash(self, cp, len); EVP_hash(self, cp, len);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment