From 1b423121ae5ccbf05ff800ea229a9941b0a52dee Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 15 Mar 2010 15:17:07 +0100 Subject: [PATCH] Add yaz_mutex_create wrapper - for debugging --- src/Makefile.am | 3 ++- src/ppmutex.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ppmutex.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ win/makefile | 1 + 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/ppmutex.c create mode 100644 src/ppmutex.h diff --git a/src/Makefile.am b/src/Makefile.am index f098000..54292be 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,8 @@ libpazpar2_a_SOURCES = pazpar2_config.c pazpar2_config.h eventl.c eventl.h \ client.c client.h connection.c connection.h host.h parameters.h \ marcmap.c marcmap.h marchash.c marchash.h \ jenkins_hash.c jenkins_hash.h normalize_record.c normalize_record.h \ - normalize_cache.c normalize_cache.h incref.c incref.h + normalize_cache.c normalize_cache.h incref.c incref.h \ + ppmutex.c ppmutex.h pazpar2_SOURCES = pazpar2.c pazpar2_LDADD = libpazpar2.a $(YAZLIB) diff --git a/src/ppmutex.c b/src/ppmutex.c new file mode 100644 index 0000000..fa187b2 --- /dev/null +++ b/src/ppmutex.c @@ -0,0 +1,55 @@ +/* This file is part of Pazpar2. + Copyright (C) 2006-2010 Index Data + +Pazpar2 is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +/** \file + \brief control MUTEX debugging +*/ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +#include "ppmutex.h" + +static int pazpar2_mutex_debug = 0; + +void pazpar2_mutex_enable_debug(int debug) +{ + pazpar2_mutex_debug = debug; +} + +void pazpar2_mutex_create(YAZ_MUTEX *p, const char *name) +{ + assert(p); + yaz_mutex_create(p); + if (pazpar2_mutex_debug && name) + yaz_mutex_set_name(*p, name); +} + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/src/ppmutex.h b/src/ppmutex.h new file mode 100644 index 0000000..c6b8c9e --- /dev/null +++ b/src/ppmutex.h @@ -0,0 +1,45 @@ +/* This file is part of Pazpar2. + Copyright (C) 2006-2010 Index Data + +Pazpar2 is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +/** \file + \brief control MUTEX debugging +*/ + +#ifndef PAZPAR2_PPMUTEX_H +#define PAZPAR2_PPMUTEXF_H + +#include + +YAZ_EXPORT +void pazpar2_mutex_enable_debug(int debug); + +YAZ_EXPORT +void pazpar2_mutex_create(YAZ_MUTEX *p, const char *name); + +#endif + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/win/makefile b/win/makefile index 934bcb3..9c0ee85 100644 --- a/win/makefile +++ b/win/makefile @@ -200,6 +200,7 @@ PAZPAR2_OBJS = \ "$(OBJDIR)\marchash.obj" \ "$(OBJDIR)\normalize_record.obj" \ "$(OBJDIR)\normalize_cache.obj" \ + "$(OBJDIR)\ppmutex.obj" \ "$(OBJDIR)\connection.obj" -- 1.7.10.4