summaryrefslogtreecommitdiff
path: root/src/stream_template.c
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2009-10-12 16:11:21 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2009-10-12 16:43:18 -0400
commit2150aca61f27dc80981a914d2b11c038e84b0c87 (patch)
tree506097d893e2804b1b919a4ad08d6a4c50b032df /src/stream_template.c
parentacf6183a53e2ce8849bc27afd51991babe69338d (diff)
downloadpycrypto-2150aca61f27dc80981a914d2b11c038e84b0c87.tar.gz
Release the global interpreter lock during encryption, decryption, and hashing.
These are the easy ones. We don't release the GIL on cipher initialization, hash initialization, or hash finalization, because those functions might make Python API calls, and we would need to add a mechism for re-acquiring the GIL in those cases.
Diffstat (limited to 'src/stream_template.c')
-rw-r--r--src/stream_template.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/stream_template.c b/src/stream_template.c
index 81e4c32..e1db5b1 100644
--- a/src/stream_template.c
+++ b/src/stream_template.c
@@ -143,8 +143,10 @@ ALG_Encrypt(ALGobject *self, PyObject *args)
_MODULE_STRING " encrypt");
return NULL;
}
+ Py_BEGIN_ALLOW_THREADS;
memcpy(buffer, str, len);
stream_encrypt(&(self->st), buffer, len);
+ Py_END_ALLOW_THREADS;
result = PyString_FromStringAndSize((char *)buffer, len);
free(buffer);
return (result);
@@ -173,8 +175,10 @@ ALG_Decrypt(ALGobject *self, PyObject *args)
_MODULE_STRING " decrypt");
return NULL;
}
+ Py_BEGIN_ALLOW_THREADS;
memcpy(buffer, str, len);
stream_decrypt(&(self->st), buffer, len);
+ Py_END_ALLOW_THREADS;
result = PyString_FromStringAndSize((char *)buffer, len);
free(buffer);
return (result);