mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
ovs-thread: Issue better diagnostics for locking uninitialized mutexes.
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@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
This commit is contained in:
@@ -55,11 +55,14 @@ 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)) { \
|
||||
ovs_abort(error, "pthread_%s_%s failed", #TYPE, #FUN); \
|
||||
ovs_abort(error, "%s: pthread_%s_%s failed", where, #TYPE, #FUN); \
|
||||
} \
|
||||
l->where = where; \
|
||||
}
|
||||
@@ -77,11 +80,14 @@ 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) { \
|
||||
ovs_abort(error, "pthread_%s_%s failed", #TYPE, #FUN); \
|
||||
ovs_abort(error, "%s: pthread_%s_%s failed", where, #TYPE, #FUN); \
|
||||
} \
|
||||
if (!error) { \
|
||||
l->where = where; \
|
||||
|
||||
Reference in New Issue
Block a user