From: Alan T. DeKok Date: Fri, 27 Aug 2010 10:48:14 +0000 (+0200) Subject: Create new mutex for Access-Challenge debug code. X-Git-Tag: release_3_0_0_beta0~1287 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=freeradius.git;a=commitdiff_plain;h=1f4e0e98473b78248eb3eba1973989e6b8a0916e Create new mutex for Access-Challenge debug code. This prevents the recursive mutex problem on some platforms. --- diff --git a/src/modules/rlm_eap/mem.c b/src/modules/rlm_eap/mem.c index 5bdf633..e0f4c6b 100644 --- a/src/modules/rlm_eap/mem.c +++ b/src/modules/rlm_eap/mem.c @@ -120,9 +120,9 @@ EAP_HANDLER *eap_handler_alloc(rlm_eap_t *inst) memset(handler, 0, sizeof(EAP_HANDLER)); if (fr_debug_flag && inst->handler_tree) { - pthread_mutex_lock(&(inst->session_mutex)); + pthread_mutex_lock(&(inst->handler_mutex)); rbtree_insert(inst->handler_tree, handler); - pthread_mutex_unlock(&(inst->session_mutex)); + pthread_mutex_unlock(&(inst->handler_mutex)); } return handler; @@ -134,9 +134,9 @@ void eap_handler_free(rlm_eap_t *inst, EAP_HANDLER *handler) return; if (inst->handler_tree) { - pthread_mutex_lock(&(inst->session_mutex)); + pthread_mutex_lock(&(inst->handler_mutex)); rbtree_deletebydata(inst->handler_tree, handler); - pthread_mutex_unlock(&(inst->session_mutex)); + pthread_mutex_unlock(&(inst->handler_mutex)); } if (handler->identity) { diff --git a/src/modules/rlm_eap/rlm_eap.c b/src/modules/rlm_eap/rlm_eap.c index 7424a52..9bcda21 100644 --- a/src/modules/rlm_eap/rlm_eap.c +++ b/src/modules/rlm_eap/rlm_eap.c @@ -66,6 +66,7 @@ static int eap_detach(void *instance) } pthread_mutex_destroy(&(inst->session_mutex)); + if (fr_debug_flag) pthread_mutex_destroy(&(inst->handler_mutex)); free(inst); @@ -255,9 +256,19 @@ static int eap_instantiate(CONF_SECTION *cs, void **instance) eap_detach(inst); return -1; } + + if (pthread_mutex_init(&(inst->handler_mutex), NULL) < 0) { + radlog(L_ERR|L_CONS, "rlm_eap: Failed initializing mutex: %s", strerror(errno)); + eap_detach(inst); + return -1; + } } - pthread_mutex_init(&(inst->session_mutex), NULL); + if (pthread_mutex_init(&(inst->session_mutex), NULL) < 0) { + radlog(L_ERR|L_CONS, "rlm_eap: Failed initializing mutex: %s", strerror(errno)); + eap_detach(inst); + return -1; + } *instance = inst; return 0; diff --git a/src/modules/rlm_eap/rlm_eap.h b/src/modules/rlm_eap/rlm_eap.h index 4802db7..84b4b50 100644 --- a/src/modules/rlm_eap/rlm_eap.h +++ b/src/modules/rlm_eap/rlm_eap.h @@ -66,6 +66,7 @@ typedef struct rlm_eap_t { #ifdef HAVE_PTHREAD_H pthread_mutex_t session_mutex; + pthread_mutex_t handler_mutex; #endif const char *xlat_name; /* no xlat's yet */