[ovs-dev] [PATCH] ovs-thread: Issue better diagnostics for locking uninitialized mutexes.

Andy Zhou azhou at nicira.com
Wed May 7 21:02:21 UTC 2014


Acked-by: Andy Zhou <azhou at nicira.com>

How about fold in the following changes as well?

diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index 83dfd62..9b6a9a5 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -62,7 +62,7 @@ static bool multithreaded;
  \
         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; \
  }

On Tue, May 6, 2014 at 3:15 PM, Ben Pfaff <blp at nicira.com> wrote:
> 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
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list