Visitar URL original
[3.10] bpo-44145: Release the GIL around HMAC_Update. (GH-26157) by miss-islington · Pull Request #26187 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20220215215942/https://github.com/python/cpython/pull/26187/files
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] bpo-44145: Release the GIL around HMAC_Update. (GH-26157) #26187

Merged
merged 1 commit into from May 17, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,3 @@
:mod:`hmac` computations were not releasing the GIL while calling the
OpenSSL ``HMAC_Update`` C API (a new feature in 3.9). This unintentionally
prevented parallel computation as other :mod:`hashlib` algorithms support.
@@ -1496,9 +1496,11 @@ _hmac_update(HMACobject *self, PyObject *obj)
}

if (self->lock != NULL) {
ENTER_HASHLIB(self);
Py_BEGIN_ALLOW_THREADS
PyThread_acquire_lock(self->lock, 1);
r = HMAC_Update(self->ctx, (const unsigned char*)view.buf, view.len);
LEAVE_HASHLIB(self);
PyThread_release_lock(self->lock);
Py_END_ALLOW_THREADS
} else {
r = HMAC_Update(self->ctx, (const unsigned char*)view.buf, view.len);
}