From f517f60a95e2f94edd1efd750024642b5941ef08 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Fri, 29 Apr 2005 10:36:05 +0000 Subject: [PATCH] Fixed the infinite recursion when calling yaz_log_level_init as the first call (before other log level or nmem_init calls) --- src/log.c | 8 +++++++- src/nmem.c | 14 +++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/log.c b/src/log.c index 859ca3a..0da70c8 100644 --- a/src/log.c +++ b/src/log.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: log.c,v 1.21 2005-01-15 19:47:13 adam Exp $ + * $Id: log.c,v 1.22 2005-04-29 10:36:05 heikki Exp $ */ /** @@ -174,6 +174,8 @@ static void rotate_log() void yaz_log_init_level (int level) { + if (!mutex_init_flag) + init_mutex(); if ( (l_level & YLOG_FLUSH) != (level & YLOG_FLUSH) ) { l_level = level; @@ -361,6 +363,8 @@ static char *clean_name(const char *name, int len, char *namebuf, int buflen) static int define_module_bit(const char *name) { int i; + if (!mutex_init_flag) + init_mutex(); for (i = 0; mask_names[i].name; i++) ; if ( (i>=MAX_MASK_NAMES) || (next_log_bit >= 1<<31 )) @@ -381,6 +385,8 @@ int yaz_log_module_level(const char *name) int i; char clean[255]; char *n = clean_name(name, strlen(name), clean, sizeof(clean)); + if (!mutex_init_flag) + init_mutex(); for (i = 0; mask_names[i].name; i++) if (0==strcmp(n,mask_names[i].name)) { diff --git a/src/nmem.c b/src/nmem.c index 4f2504e..0ce4ca6 100644 --- a/src/nmem.c +++ b/src/nmem.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: nmem.c,v 1.14 2005-01-21 09:23:27 adam Exp $ + * $Id: nmem.c,v 1.15 2005-04-29 10:36:05 heikki Exp $ */ /** @@ -94,12 +94,6 @@ struct nmem_mutex { YAZ_EXPORT void nmem_mutex_create(NMEM_MUTEX *p) { - if (!log_level_initialized) - { - log_level = yaz_log_module_level("nmem"); - log_level_initialized = 1; - } - if (!*p) { *p = (NMEM_MUTEX) malloc (sizeof(**p)); @@ -111,6 +105,12 @@ YAZ_EXPORT void nmem_mutex_create(NMEM_MUTEX *p) pth_mutex_init (&(*p)->m_handle); #endif } + if (!log_level_initialized) + { + log_level_initialized = 1; + log_level = yaz_log_module_level("nmem"); + } + } YAZ_EXPORT void nmem_mutex_enter(NMEM_MUTEX p) -- 1.7.10.4