Commit 572501f9 authored by Pekka Pessi's avatar Pekka Pessi

auth_module.c: use reference counting provided by su_home_t

darcs-hash:20070202071811-65a35-fa8f02a0460ef02aeb6a5919c54143f5264f7936.gz
parent f96079e5
......@@ -76,6 +76,7 @@ static char const __func__[] = "auth_mod";
char const auth_internal_server_error[] = "Internal server error";
static void auth_call_scheme_destructor(void *);
static void auth_md5_hmac_key(auth_mod_t *am);
HTABLE_PROTOS_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
......@@ -94,7 +95,7 @@ auth_mod_t *auth_mod_alloc(auth_scheme_t *scheme,
if ((am = su_home_new(scheme->asch_size))) {
am->am_scheme = scheme;
am->am_refcount = 1;
su_home_destructor(am->am_home, auth_call_scheme_destructor);
}
return am;
......@@ -246,10 +247,14 @@ int auth_init_default(auth_mod_t *am,
/** Destroy (a reference to) an authentication module. */
void auth_mod_destroy(auth_mod_t *am)
{
if (am && am->am_refcount != 0 && --am->am_refcount == 0) {
su_home_unref(am->am_home);
}
/** Call scheme-specific destructor function. */
static void auth_call_scheme_destructor(void *arg)
{
auth_mod_t *am = arg;
am->am_scheme->asch_destroy(am);
su_home_zap(am->am_home);
}
}
/** Do-nothing destroy function.
......@@ -264,18 +269,13 @@ void auth_destroy_default(auth_mod_t *am)
/** Create a new reference to authentication module. */
auth_mod_t *auth_mod_ref(auth_mod_t *am)
{
if (!am || am->am_refcount == 0)
return NULL;
am->am_refcount++;
return am;
return (auth_mod_t *)su_home_ref(am->am_home);
}
/** Destroy a reference to an authentication module. */
void auth_mod_unref(auth_mod_t *am)
{
auth_mod_destroy(am);
su_home_unref(am->am_home);
}
/** Get authenticatin module name. @NEW_1_12_4. */
......
......@@ -124,7 +124,7 @@ struct stat;
struct auth_mod_t
{
su_home_t am_home[1];
unsigned am_refcount; /**< Number of references to this module */
unsigned _am_refcount; /**< Not used */
/* User database / cache */
char const *am_db; /**< User database file name */
......
......@@ -769,8 +769,6 @@ int test_digest_client()
{
char const *nonce1, *nextnonce, *nonce2;
reinit_as(as); auth_mod_destroy(am); aucs = NULL;
TEST_1(am = auth_mod_create(NULL,
AUTHTAG_METHOD("Digest"),
AUTHTAG_REALM("ims3.so.noklab.net"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment