#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);
+ }
}
}