[ovs-dev] [PATCH] ovs-thread: Issue better diagnostics for locking uninitialized mutexes.
Ben Pfaff
blp at nicira.com
Tue May 6 22:15:20 UTC 2014
This makes the message issued refer to the file and line that called
ovs_mutex_lock(), instead of to the file and line *inside*
ovs_mutex_lock().
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
lib/ovs-thread.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index fbdd7fc..83dfd62 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -55,7 +55,10 @@ static bool multithreaded;
int error; \
\
/* Verify that 'l' was initialized. */ \
- ovs_assert(l->where); \
+ if (OVS_UNLIKELY(!l->where)) { \
+ ovs_abort(0, "%s: %s() passed uninitialized ovs_"#TYPE, \
+ where, __func__); \
+ } \
\
error = pthread_##TYPE##_##FUN(&l->lock); \
if (OVS_UNLIKELY(error)) { \
@@ -77,7 +80,10 @@ LOCK_FUNCTION(rwlock, wrlock);
int error; \
\
/* Verify that 'l' was initialized. */ \
- ovs_assert(l->where); \
+ if (OVS_UNLIKELY(!l->where)) { \
+ ovs_abort(0, "%s: %s() passed uninitialized ovs_"#TYPE, \
+ where, __func__); \
+ } \
\
error = pthread_##TYPE##_##FUN(&l->lock); \
if (OVS_UNLIKELY(error) && error != EBUSY) { \
--
1.7.10.4
More information about the dev
mailing list