aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib_pypy/crypt/__init__.py')
-rw-r--r--lib_pypy/crypt/__init__.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib_pypy/crypt/__init__.py b/lib_pypy/crypt/__init__.py
index a5790e83ad..83e516011f 100644
--- a/lib_pypy/crypt/__init__.py
+++ b/lib_pypy/crypt/__init__.py
@@ -4,6 +4,12 @@ CFFI based implementation of the crypt module
import sys
import cffi
+import thread
+_lock = thread.allocate_lock()
+
+try: from __pypy__ import builtinify
+except ImportError: builtinify = lambda f: f
+
ffi = cffi.FFI()
ffi.cdef('char *crypt(char *word, char *salt);')
@@ -14,8 +20,10 @@ except OSError:
raise ImportError('crypt not available')
+@builtinify
def crypt(word, salt):
- res = lib.crypt(word, salt)
- if not res:
- return None
- return ffi.string(res)
+ with _lock:
+ res = lib.crypt(word, salt)
+ if not res:
+ return None
+ return ffi.string(res)