diff options
author | Rob Austein <sra@hactrn.net> | 2015-09-20 15:11:21 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-09-20 15:11:21 -0400 |
commit | 91b051e349e3644b4a2114ec0366f8bd7d794f56 (patch) | |
tree | 12f79111c889600e38d1b709930dda2a8068d7af | |
parent | fc79084886aa81e7414a4bd2aba48aa96a0b641b (diff) |
Debug mutex implementation.
-rw-r--r-- | py11/mutex.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/py11/mutex.py b/py11/mutex.py index 5ad30ba..1d99aa1 100644 --- a/py11/mutex.py +++ b/py11/mutex.py @@ -1,6 +1,8 @@ # Optional mutex implementation. -from struct import pack, unpack +from struct import pack, unpack +from .types import * +from .exceptions import * # This controls how big our mutex handles are. encoded_format = "=L" @@ -23,10 +25,12 @@ def p11_callback(func): def wrapper(self, arg): try: func(self, arg) - except ThreadError: - return CKR_MUTEX_NOT_LOCKED - except: - return CKR_FUNCTION_FAILED + except ThreadError, e: + print "Failed: %s" % e + return CKR_MUTEX_NOT_LOCKED.ckr_code + except Exception, e: + print "Failed: %s" % e + return CKR_FUNCTION_FAILED.ckr_code else: return CKR_OK return wrapper @@ -47,7 +51,7 @@ class MutexDB(object): @p11_callback def create(self, handle_ptr): handle = self.find_free_handle() - self.mutexes[handle] = self.mutex_type(handle) + self.mutexes[handle] = Mutex(handle) handle_ptr[0] = self.mutexes[handle].encoded @p11_callback |