AC_C_INLINE
-YAZ_INIT([static icu threads],[4.0.1])
+YAZ_INIT([static icu server],[4.0.1])
if test -z "$YAZLIB"; then
AC_MSG_ERROR([YAZ development libraries missing])
fi
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
+ normalize_cache.c normalize_cache.h incref.c incref.h
pazpar2_SOURCES = pazpar2.c
pazpar2_LDADD = libpazpar2.a $(YAZLIB)
error(rs, PAZPAR2_NO_SERVICE, service_name ? service_name : "unnamed");
return;
}
- service_incref(service);
}
s = http_session_create(service);
--- /dev/null
+/* 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 incref.c
+ \brief MUTEX protect ref counts
+*/
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "incref.h"
+
+void pazpar2_incref(int *ref, YAZ_MUTEX mutex)
+{
+ yaz_mutex_enter(mutex);
+ (*ref)++;
+ yaz_mutex_leave(mutex);
+}
+
+
+int pazpar2_decref(int *ref, YAZ_MUTEX mutex)
+{
+ int value ;
+ yaz_mutex_enter(mutex);
+ value = --(*ref);
+ yaz_mutex_leave(mutex);
+ return value;
+}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+/* 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 incref.h
+ \brief MUTEX protect ref counts
+*/
+
+#ifndef PAZPAR2_INCREF_H
+#define PAZPAR2_INCREF_H
+
+#include <yaz/mutex.h>
+
+void pazpar2_incref(int *ref, YAZ_MUTEX mutex);
+int pazpar2_decref(int *ref, YAZ_MUTEX mutex);
+
+#endif
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#include "incref.h"
#include "pazpar2_config.h"
#include "settings.h"
#include "eventl.h"
NMEM nmem = nmem_create();
service = nmem_malloc(nmem, sizeof(struct conf_service));
+ service->mutex = 0;
service->ref_count = 1;
service->nmem = nmem;
service->next = 0;
{
if (service)
{
- assert(service->ref_count > 0);
- service->ref_count--;
- if (service->ref_count == 0)
+ yaz_log(YLOG_LOG, "service_destroy. p=%p cnt=%d", service,
+ service->ref_count);
+ if (!pazpar2_decref(&service->ref_count, service->mutex))
{
pp2_charset_destroy(service->relevance_pct);
pp2_charset_destroy(service->sort_pct);
pp2_charset_destroy(service->mergekey_pct);
+ yaz_mutex_destroy(&service->mutex);
nmem_destroy(service->nmem);
}
}
void service_incref(struct conf_service *service)
{
- service->ref_count++;
+ yaz_log(YLOG_LOG, "service_incref. p=%p cnt=%d", service,
+ service->ref_count);
+ pazpar2_incref(&service->ref_count, service->mutex);
}
static int parse_metadata(struct conf_service *service, xmlNode *n,
{
inherit_server_settings(service);
resolve_databases(service);
+ assert(service->mutex == 0);
+ yaz_mutex_create(&service->mutex);
}
return service;
}
struct conf_service *s = server->service;
for (; s; s = s->next)
if (s->id && service_id && 0 == strcmp(s->id, service_id))
- return s;
+ break;
else if (!s->id && !service_id)
- return s;
- return 0;
+ break;
+ if (s)
+ service_incref(s);
+ return s;
}
xmlChar *number = xmlGetProp(n, (xmlChar *) "number");
if (number)
{
- config->no_threads = atoi(number);
+ config->no_threads = atoi((const char *) number);
xmlFree(number);
}
}
{
struct conf_service *s = ser->service;
for (;s ; s = s->next)
+ {
resolve_databases(s);
+ assert(s->mutex == 0);
+ yaz_mutex_create(&s->mutex);
+ }
}
}
#include "normalize_cache.h"
#include <yaz/nmem.h>
+#include <yaz/mutex.h>
#include "charsets.h"
enum conf_metadata_type {
// however, only a single service is possible.
struct conf_service
{
+ YAZ_MUTEX mutex;
int num_metadata;
struct conf_metadata *metadata;
int num_sortkeys;
void expand_settings_array(struct setting ***set_ar, int *num, int offset,
NMEM nmem);
+void pazpar2_chan_man_start(int no_threads);
#endif