From 91b051e349e3644b4a2114ec0366f8bd7d794f56 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 20 Sep 2015 15:11:21 -0400 Subject: Debug mutex implementation. --- py11/mutex.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'py11') 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 -- cgit v1.2.3