From: Adam Dickmeiss Date: Fri, 5 May 2000 13:48:03 +0000 (+0000) Subject: Fixed locking for metafiles. X-Git-Tag: ZEBRA.1.1~74 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=c1a85f9caaa8476a69b392349e90b7c4981e7db3;p=idzebra-moved-to-github.git Fixed locking for metafiles. --- diff --git a/bfile/mfile.c b/bfile/mfile.c index 6942bbd..6afd611 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: mfile.c,v $ - * Revision 1.38 2000-03-20 19:08:35 adam + * Revision 1.39 2000-05-05 13:48:03 adam + * Fixed locking for metafiles. + * + * Revision 1.38 2000/03/20 19:08:35 adam * Added remote record import using Z39.50 extended services and Segment * Requests. * @@ -324,6 +327,7 @@ MFile_area mf_init(const char *name, const char *spec) if (!meta_f) { meta_f = (meta_file *) xmalloc(sizeof(*meta_f)); + zebra_mutex_init (&meta_f->mutex); meta_f->ma = ma; meta_f->next = ma->mfiles; meta_f->open = 0; diff --git a/include/zebra-lock.h b/include/zebra-lock.h index ccdd95f..44de1f4 100644 --- a/include/zebra-lock.h +++ b/include/zebra-lock.h @@ -23,6 +23,7 @@ typedef struct { int dummy; # endif #endif + int state; } Zebra_mutex; YAZ_EXPORT int zebra_mutex_init (Zebra_mutex *p); 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 diff --git a/win/makefile b/win/makefile index b7a43c2..1bc68c8 100644 --- a/win/makefile +++ b/win/makefile @@ -1,11 +1,11 @@ # Z'mbol makefile for MS NMAKE -# $Id: makefile,v 1.4 2000-04-19 14:35:59 adam Exp $ +# $Id: makefile,v 1.5 2000-05-05 13:48:03 adam Exp $ ########################################################### ############### Parameters ########################################################### -DEBUG=0 # 0 for release, 1 for debug +DEBUG=1 # 0 for release, 1 for debug default: all @@ -392,7 +392,10 @@ $(ALL_OBJS): makefile ########################################################### # # $Log: makefile,v $ -# Revision 1.4 2000-04-19 14:35:59 adam +# Revision 1.5 2000-05-05 13:48:03 adam +# Fixed locking for metafiles. +# +# Revision 1.4 2000/04/19 14:35:59 adam # WIN32 update (this version is known not to work on Windows). # # Revision 1.3 2000/04/17 14:22:00 adam