diff options
author | djm <devnull@localhost> | 2009-10-01 13:09:52 +0000 |
---|---|---|
committer | djm <devnull@localhost> | 2009-10-01 13:09:52 +0000 |
commit | 6817d1859223686e92ce766ef084b43dcc5a10d4 (patch) | |
tree | 2933a5f02e136efd481a7b9818f0a2d677110527 | |
parent | ffeb7a6ef295f1ed4b0d9988855acd602410fde9 (diff) | |
download | py-bcrypt-6817d1859223686e92ce766ef084b43dcc5a10d4.tar.gz |
- (djm) Allow Python threads to run during (potentially lengthy) bcrypt
operation. Patch from vijay AT meebo-inc.com
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | bcrypt/bcrypt_python.c | 12 |
2 files changed, 15 insertions, 1 deletions
@@ -1,3 +1,7 @@ +20091001 + - (djm) Allow Python threads to run during (potentially lengthy) bcrypt + operation. Patch from vijay AT meebo-inc.com + 20060808 - (djm) Add support for Win32 diff --git a/bcrypt/bcrypt_python.c b/bcrypt/bcrypt_python.c index 54d1f40..b505c3b 100644 --- a/bcrypt/bcrypt_python.c +++ b/bcrypt/bcrypt_python.c @@ -72,7 +72,17 @@ bcrypt_hashpw(PyObject *self, PyObject *args, PyObject *kw_args) if (!PyArg_ParseTupleAndKeywords(args, kw_args, "ss:hashpw", keywords, &password, &salt)) return NULL; - if ((ret = pybc_bcrypt(password, salt)) == NULL || + + char *password_copy = strdup(password); + char *salt_copy = strdup(salt); + + Py_BEGIN_ALLOW_THREADS; + ret = pybc_bcrypt(password_copy, salt_copy); + Py_END_ALLOW_THREADS; + + free(password_copy); + free(salt_copy); + if ((ret == NULL) || strcmp(ret, ":") == 0) { PyErr_SetString(PyExc_ValueError, "Invalid salt"); return NULL; |