]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Log failure details for mutex errors 684/head
authorRobbie Harwood <rharwood@redhat.com>
Tue, 8 Aug 2017 22:24:32 +0000 (18:24 -0400)
committerGreg Hudson <ghudson@mit.edu>
Wed, 9 Aug 2017 20:26:58 +0000 (16:26 -0400)
Log only when assertions themselves are enabled in order to keep code
small.

src/include/k5-thread.h

index 3e3901d6e8fbc8ac2e36c9817a028c0622924b0c..a3101239d8a5cf5afd8b276f8061ed8476bae908 100644 (file)
      More to be added, perhaps.  */
 
 #include <assert.h>
+#ifndef NDEBUG
+#include <stdio.h>
+#include <string.h>
+#endif
 
 /* The mutex structure we use, k5_mutex_t, is defined to some
    OS-specific bits.  The use of multiple layers of typedefs are an
@@ -363,12 +367,24 @@ static inline int k5_mutex_finish_init(k5_mutex_t *m)
 static inline void k5_mutex_lock(k5_mutex_t *m)
 {
     int r = k5_os_mutex_lock(m);
+#ifndef NDEBUG
+    if (r != 0) {
+        fprintf(stderr, "k5_mutex_lock: Received error %d (%s)\n",
+                r, strerror(r));
+    }
+#endif
     assert(r == 0);
 }
 
 static inline void k5_mutex_unlock(k5_mutex_t *m)
 {
     int r = k5_os_mutex_unlock(m);
+#ifndef NDEBUG
+    if (r != 0) {
+        fprintf(stderr, "k5_mutex_unlock: Received error %d (%s)\n",
+                r, strerror(r));
+    }
+#endif
     assert(r == 0);
 }