From 2a459318750cf93818744102e714f4c600fa11f0 Mon Sep 17 00:00:00 2001 From: aland Date: Fri, 24 May 2002 17:31:23 +0000 Subject: [PATCH] Don't bother locking the FD ourselves, as it appears to cause locks on some platforms. Instead, don't lock it, but declare the module to be single threaded. --- src/modules/rlm_counter/rlm_counter.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/modules/rlm_counter/rlm_counter.c b/src/modules/rlm_counter/rlm_counter.c index bc1bd1e..0ee2040 100644 --- a/src/modules/rlm_counter/rlm_counter.c +++ b/src/modules/rlm_counter/rlm_counter.c @@ -130,9 +130,7 @@ static int counter_cmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALUE_ key_datum.dptr = key_vp->strvalue; key_datum.dsize = key_vp->length; - if (data->fd >= 0) rad_lockfd(data->fd, sizeof(int)); count_datum = gdbm_fetch(data->gdbm, key_datum); - if (data->fd >= 0) rad_unlockfd(data->fd, sizeof(int)); if (count_datum.dptr == NULL) { return -1; @@ -430,7 +428,6 @@ static int counter_accounting(void *instance, REQUEST *request) key_datum.dptr = key_vp->strvalue; key_datum.dsize = key_vp->length; - if (data->fd >= 0) rad_lockfd(data->fd, sizeof(int)); count_datum = gdbm_fetch(data->gdbm, key_datum); if (count_datum.dptr == NULL) counter = 0; @@ -471,7 +468,6 @@ static int counter_accounting(void *instance, REQUEST *request) count_datum.dsize = sizeof(int); rcode = gdbm_store(data->gdbm, key_datum, count_datum, GDBM_REPLACE); - if (data->fd >= 0) rad_unlockfd(data->fd, sizeof(int)); if (rcode < 0) { radlog(L_ERR, "rlm_counter: Failed storing data to %s: %s", data->filename, gdbm_strerror(gdbm_errno)); @@ -560,9 +556,7 @@ static int counter_authorize(void *instance, REQUEST *request) key_datum.dptr = key_vp->strvalue; key_datum.dsize = key_vp->length; - if (data->fd >= 0) rad_lockfd(data->fd, sizeof(int)); count_datum = gdbm_fetch(data->gdbm, key_datum); - if (data->fd >= 0) rad_unlockfd(data->fd, sizeof(int)); if (count_datum.dptr != NULL){ memcpy(&counter, count_datum.dptr, sizeof(int)); free(count_datum.dptr); @@ -666,7 +660,7 @@ static int counter_detach(void *instance) */ module_t rlm_counter = { "Counter", - RLM_TYPE_THREAD_SAFE, /* type */ + RLM_TYPE_THREAD_UNSAFE, /* type */ NULL, /* initialization */ counter_instantiate, /* instantiation */ { -- 2.1.4