aboutsummaryrefslogtreecommitdiff
path: root/py11
diff options
context:
space:
mode:
Diffstat (limited to 'py11')
-rw-r--r--py11/mutex.py16
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