X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=util%2Fzebra-lock.c;h=dfd8ceae2ace6073dcd380a56e5043456861313a;hb=c1a85f9caaa8476a69b392349e90b7c4981e7db3;hp=769de1babe451abf192b3130f4551c9dede7b356;hpb=b9ba556f29428d79db2a874b1a33504290125216;p=idzebra-moved-to-github.git diff --git a/util/zebra-lock.c b/util/zebra-lock.c index 769de1b..dfd8cea 100644 --- a/util/zebra-lock.c +++ b/util/zebra-lock.c @@ -1,10 +1,17 @@ #include +#include #include + int zebra_mutex_init (Zebra_mutex *p) { + if (p->state == 1) + { + fprintf (stderr, "zebra_mutex_init. state=%d\n", p->state); + } + p->state = 1; #if HAVE_PTHREAD_H pthread_mutex_init (&p->mutex, 0); #endif @@ -16,6 +23,11 @@ int zebra_mutex_init (Zebra_mutex *p) int zebra_mutex_destroy (Zebra_mutex *p) { + --(p->state); + if (p->state != 0) + { + fprintf (stderr, "zebra_mutex_destroy. state = %d\n", p->state); + } #if HAVE_PTHREAD_H pthread_mutex_destroy (&p->mutex); #endif @@ -27,6 +39,10 @@ int zebra_mutex_destroy (Zebra_mutex *p) int zebra_mutex_lock (Zebra_mutex *p) { + if (p->state != 1) + { + fprintf (stderr, "zebra_mutex_lock. state = %d\n", p->state); + } #if HAVE_PTHREAD_H pthread_mutex_lock (&p->mutex); #endif @@ -38,6 +54,10 @@ int zebra_mutex_lock (Zebra_mutex *p) int zebra_mutex_unlock (Zebra_mutex *p) { + if (p->state != 1) + { + fprintf (stderr, "zebra_mutex_unlock. state = %d\n", p->state); + } #if HAVE_PTHREAD_H pthread_mutex_unlock (&p->mutex); #endif