[Cryptech-Commits] [sw/pkcs11] 02/07: Debug mutex implementation.

git at cryptech.is git at cryptech.is
Mon Sep 21 23:26:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ecdsa
in repository sw/pkcs11.

commit 91b051e349e3644b4a2114ec0366f8bd7d794f56
Author: Rob Austein <sra at hactrn.net>
Date:   Sun Sep 20 15:11:21 2015 -0400

    Debug mutex implementation.
---
 py11/mutex.py | 16 ++++++++++------
 1 file 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



More information about the Commits mailing list